Sha256: e02d5dbb0e3a2602add94d0dc9eadb69799ee9fb62919b5fb39097375a9cb152

Contents?: true

Size: 924 Bytes

Versions: 3

Compression:

Stored size: 924 Bytes

Contents

# frozen_string_literal: true

require 'test_helper'

class TestTableOfContentsTag < Minitest::Test
  include Liquid

  def setup
    @stubbed_context  = Struct.new(:registers)
    @stubbed_context1 = Struct.new(:config)
    @stubbed_context2 = Struct.new(:toc, :content)
  end

  def test_toc_tag
    context = @stubbed_context.new(
      page: @stubbed_context2.new({ 'toc' => false }, '<h1>test</h1>'), 
      site: @stubbed_context1.new({ 'toc' => nil })
    )
    tag = Jekyll::TocTag.parse('toc_tag', '', Tokenizer.new(''), ParseContext.new)
    assert_equal tag.render(context), "<ul class=\"section-nav\">\n<li class=\"toc-entry toc-h1\"><a href=\"#test\">test</a></li>\n</ul>"
  end

  def test_toc_tag_returns_empty_string
    context = @stubbed_context.new(page: { 'toc' => false })
    tag = Jekyll::TocTag.parse('toc_tag', '', Tokenizer.new(''), ParseContext.new)
    assert_empty tag.render(context)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jekyll-toc-0.12.1 test/test_toc_tag.rb
jekyll-toc-0.12.0 test/test_toc_tag.rb
jekyll-toc-0.12.0.rc3 test/test_toc_tag.rb