Sha256: 1ef19fed8d1008d66a994bc52af1a50052c4c8e9d771b63e304ab7a98aafd97e

Contents?: true

Size: 876 Bytes

Versions: 10

Compression:

Stored size: 876 Bytes

Contents

require 'test_helper'

class TestTOCFilter < Minitest::Test
  include TestHelpers

  def setup
    read_html_and_create_parser
  end

  def test_injects_anchors
    html = @parser.toc

    assert_match(%r{<a id="simple-h1" class="anchor" href="#simple-h1" aria-hidden="true"><span.*span></a>Simple H1}, html)
  end

  def test_nested_toc
    doc = Nokogiri::HTML(@parser.toc)
    nested_h6_text = doc.css('ul.section-nav')
                        .css('li.toc-h1')
                        .css('li.toc-h2')
                        .css('li.toc-h3')
                        .css('li.toc-h4')
                        .css('li.toc-h5')
                        .css('li.toc-h6')
                        .text
    assert_equal('Simple H6', nested_h6_text)
  end

  def test_injects_toc_container
    html = @parser.toc

    assert_match(/<ul class="section-nav">/, html)
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
jekyll-toc-0.7.0.alpha1 test/test_toc_filter.rb
jekyll-toc-0.6.0 test/test_toc_filter.rb
jekyll-toc-0.5.2 test/test_toc_filter.rb
jekyll-toc-0.5.1 test/test_toc_filter.rb
jekyll-toc-0.5.0 test/test_toc_filter.rb
jekyll-toc-0.5.0.rc test/test_toc_filter.rb
jekyll-toc-0.4.0 test/test_toc_filter.rb
jekyll-toc-0.4.0.rc2 test/test_toc_filter.rb
jekyll-toc-0.4.0.rc test/test_toc_filter.rb
jekyll-toc-0.3.0 test/test_toc_filter.rb