Sha256: 3857e6cee61c583ff2f474e36204922ae2a487ace6e57118f9dc01d1d2ff4b4c

Contents?: true

Size: 907 Bytes

Versions: 12

Compression:

Stored size: 907 Bytes

Contents

# frozen_string_literal: true

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

12 entries across 12 versions & 1 rubygems

Version Path
jekyll-toc-0.10.0 test/test_toc_filter.rb
jekyll-toc-0.9.1 test/test_toc_filter.rb
jekyll-toc-0.9.0 test/test_toc_filter.rb
jekyll-toc-0.9.0.beta2 test/test_toc_filter.rb
jekyll-toc-0.9.0.beta1 test/test_toc_filter.rb
jekyll-toc-0.8.0 test/test_toc_filter.rb
jekyll-toc-0.8.0.rc1 test/test_toc_filter.rb
jekyll-toc-0.8.0.beta2 test/test_toc_filter.rb
jekyll-toc-0.8.0.beta1 test/test_toc_filter.rb
jekyll-toc-0.7.1 test/test_toc_filter.rb
jekyll-toc-0.7.0 test/test_toc_filter.rb
jekyll-toc-0.7.0.beta1 test/test_toc_filter.rb