Sha256: 2fa96742c923f57bce3451f97cb00ccb84b9ae2cdc34e917ea101dd0627ffc21

Contents?: true

Size: 1.32 KB

Versions: 8

Compression:

Stored size: 1.32 KB

Contents

require 'webgen/test'
require 'webgen/node'

class LangbarTagTest < Webgen::TagTestCase

  plugin_files [
    'webgen/plugins/tags/langbar.rb',
    'webgen/plugins/filehandlers/directory.rb',
    'webgen/plugins/filehandlers/page.rb',
  ]
  plugin_to_test 'Tag/Langbar'


  def test_process_tag
    root = @manager['Core/FileHandler'].instance_eval { build_tree }

    node = root.resolve_node( 'index.en.page' )
    de_link = '<a href="index.de.html">de</a>'
    en_link = '<span>en</span>'
    check_results( node, "#{de_link} | #{en_link}", de_link, "#{de_link} | #{en_link}", de_link )

    node = root.resolve_node( 'file1.page' )
    link = '<span>en</span>'
    check_results( node, link, '', '', '' )
  end


  def check_results( node, both_true, both_false, first_false, second_false )
    set_config( 'showSingleLang'=>true, 'showOwnLang'=>true )
    assert_equal( both_true, @plugin.process_tag( 'langbar', [node] ) )

    set_config( 'showSingleLang'=>false, 'showOwnLang'=>false )
    assert_equal( both_false, @plugin.process_tag( 'langbar', [node] ) )

    set_config( 'showSingleLang'=>false, 'showOwnLang'=>true )
    assert_equal( first_false, @plugin.process_tag( 'langbar', [node] ) )

    set_config( 'showSingleLang'=>true, 'showOwnLang'=>false )
    assert_equal( second_false, @plugin.process_tag( 'langbar', [node] ) )
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
webgen-0.4.2 test/unittests/tc_tags_langbar.rb
webgen-0.4.1 test/unittests/tc_tags_langbar.rb
webgen-0.4.0 test/unittests/tc_tags_langbar.rb
webgen-0.4.3 test/unittests/tc_tags_langbar.rb
webgen-0.4.5 test/unittests/tc_tags_langbar.rb
webgen-0.4.4 test/unittests/tc_tags_langbar.rb
webgen-0.4.6 test/unittests/tc_tags_langbar.rb
webgen-0.4.7 test/unittests/tc_tags_langbar.rb