# -*- encoding: utf-8 -*- require 'test/unit' require 'helper' require 'webgen/tree' require 'webgen/page' require 'webgen/contentprocessor' class TestContentProcessorHead < Test::Unit::TestCase include Test::WebsiteHelper def setup super @obj = Webgen::ContentProcessor::Head.new @root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/') @node = Webgen::Node.new(@root, 'test.en', 'test', {'lang' => 'en'}) end def test_meta_information context = Webgen::Context.new(:chain => [@node]) context.content = '' @node['meta'] = {'other' => 'me'} @obj.call(context) assert_equal("\n", context.content) end def test_persistent_information context = Webgen::Context.new(:chain => [@node]) context.content = '' context.clone.persistent[:cp_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<"'} } @obj.call(context) assert_equal("\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", context.content) end def test_links_to_other_lang_nodes context = Webgen::Context.new(:chain => [@node]) context.content = '' @obj.call(context) assert_equal("", context.content) de_node = Webgen::Node.new(@root, 'test.de', 'test', {'lang' => 'de'}) @obj.call(context) assert_equal("\n", context.content) context.content = '' de_node['title'] = 'Deutscher Titel' @obj.call(context) assert_equal("\n", context.content) end def test_javascript_and_css_links context = Webgen::Context.new(:chain => [@node]) context.content = '' @node['link'] = {'javascript' => 'http://example.org', 'css' => ['http://example.org', 'test', 'unknown']} @obj.call(context) assert_equal("\n" + "\n" + "\n", context.content) end def test_generic_links context = Webgen::Context.new(:chain => [@node]) context.content = '' @node['link'] = {'next' => 'test', 'start' => {'type' => 'text/xhtml', 'href' => 'http://example.org'}, 'alternate' => ['test', {'type' => 'text/html', 'href' => 'test'}, {'href' => 'unknown'}, {'type' => 'text/html'}] } @obj.call(context) assert_equal("\n" + "\n" + "\n" + "\n", context.content) context.content = '' @obj.call(context) assert_equal("\n" + "\n" + "\n" + "\n", context.content) end end