Sha256: 19e5e484a2b3f739ede6d9e228517f6f01e1e308d4829bf75aac66558c1dd0fd

Contents?: true

Size: 1.13 KB

Versions: 13

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

require 'test_helper'

class TestOptionError < Minitest::Test
  BASE_HTML = '<h1>h1</h1>'
  EXPECTED_HTML = <<~HTML
    <ul class="section-nav">
    <li class="toc-entry toc-h1"><a href="#h1">h1</a></li>
    </ul>
  HTML

  def test_option_is_nil
    parser = Jekyll::TableOfContents::Parser.new(BASE_HTML, nil)
    doc = Nokogiri::HTML(parser.toc)
    expected = EXPECTED_HTML
    assert_equal(expected, doc.css('ul.section-nav').to_s)
  end

  def test_option_is_epmty_string
    parser = Jekyll::TableOfContents::Parser.new(BASE_HTML, '')
    doc = Nokogiri::HTML(parser.toc)
    expected = EXPECTED_HTML
    assert_equal(expected, doc.css('ul.section-nav').to_s)
  end

  def test_option_is_string
    parser = Jekyll::TableOfContents::Parser.new(BASE_HTML, 'string')
    doc = Nokogiri::HTML(parser.toc)
    expected = EXPECTED_HTML
    assert_equal(expected, doc.css('ul.section-nav').to_s)
  end

  def test_option_is_array
    parser = Jekyll::TableOfContents::Parser.new(BASE_HTML, [])
    doc = Nokogiri::HTML(parser.toc)
    expected = EXPECTED_HTML
    assert_equal(expected, doc.css('ul.section-nav').to_s)
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
jekyll-toc-0.13.1 test/parser/test_option_error.rb
jekyll-toc-0.13.0 test/parser/test_option_error.rb
jekyll-toc-0.12.2 test/parser/test_option_error.rb
jekyll-toc-0.12.1 test/parser/test_option_error.rb
jekyll-toc-0.12.0 test/parser/test_option_error.rb
jekyll-toc-0.12.0.rc3 test/parser/test_option_error.rb
jekyll-toc-0.12.0.rc2 test/parser/test_option_error.rb
jekyll-toc-0.12.0.rc1 test/parser/test_option_error.rb
jekyll-toc-0.11.0 test/parser/test_option_error.rb
jekyll-toc-0.10.0 test/test_option_error.rb
jekyll-toc-0.9.1 test/test_option_error.rb
jekyll-toc-0.9.0 test/test_option_error.rb
jekyll-toc-0.9.0.beta2 test/test_option_error.rb