# -*- encoding: utf-8 -*- require 'webgen/test_helper' require 'webgen/content_processor/html_head' class TestHtmlHead < MiniTest::Unit::TestCase include Webgen::TestHelper def setup setup_website @obj = Webgen::ContentProcessor::HtmlHead @root = Webgen::Node.new(@website.tree.dummy_root, '/', '/') @node = Webgen::Node.new(@root, 'test', 'test.en', {'lang' => 'en'}) end def test_call context = Webgen::Context.new(@website, :chain => [@node]) context.content = "" de_node = Webgen::Node.new(@root, 'test', 'test.de', {'lang' => 'de'}) assert_equal("\n", @obj.call(context).content) end def test_tags_from_context_data @node.meta_info['meta'] = {'other' => 'me'} context = Webgen::Context.new(@website, :chain => [@node]) context.persistent[:cp_html_head] = { :js_file => ['hallo.js', 'hallo2.js', 'hallo.js'], :js_inline => ["somescript", "anotherscript"], :css_file => ['hallo.css', 'hallo2.css', 'hallo.css'], :css_inline => ["somestyle", "anotherstyle"], :meta => {:lucky => 'me<"'} } assert_equal("\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", @obj.tags_from_context_data(context)) end def test_links_to_translations context = Webgen::Context.new(@website, :chain => [@node]) de_node = Webgen::Node.new(@root, 'test', 'test.de', {'lang' => 'de'}) assert_equal("\n", @obj.links_to_translations(context)) de_node.meta_info['title'] = 'Deutscher Titel' assert_equal("\n", @obj.links_to_translations(context)) end def test_links_from_link_meta_info context = Webgen::Context.new(@website, :chain => [@node]) @node.meta_info['link'] = {'javascript' => 'http://example.org', 'css' => ['http://example.org', 'test', 'unknown']} assert_equal("\n" + "\n" + "\n", @obj.links_from_link_meta_info(context)) @node.meta_info['link'] = {'next' => 'test', 'start' => {'type' => 'text/xhtml', 'href' => 'http://example.org'}, 'alternate' => ['test', {'type' => 'text/html', 'href' => 'test'}, {'href' => 'unknown'}, {'type' => 'text/html'}] } assert_equal("\n" + "\n" + "\n" + "\n", @obj.links_from_link_meta_info(context)) end end