summaryrefslogtreecommitdiff
path: root/spec/lib/banzai/filter/table_of_contents_filter_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/banzai/filter/table_of_contents_filter_spec.rb')
-rw-r--r--spec/lib/banzai/filter/table_of_contents_filter_spec.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/lib/banzai/filter/table_of_contents_filter_spec.rb b/spec/lib/banzai/filter/table_of_contents_filter_spec.rb
index 6a5d003e87f..219a0581d13 100644
--- a/spec/lib/banzai/filter/table_of_contents_filter_spec.rb
+++ b/spec/lib/banzai/filter/table_of_contents_filter_spec.rb
@@ -70,6 +70,22 @@ describe Banzai::Filter::TableOfContentsFilter, lib: true do
end
end
+ describe 'TOC tag' do
+ it 'replaces [[<em>TOC</em>]] with ToC result' do
+ doc = described_class.call("<p>[[<em>TOC</em>]]</p><h1>Foo</h1>")
+
+ expect(doc.to_html).not_to include('TOC')
+ expect(doc.to_html).to include('<a href="#foo">Foo</a>')
+ end
+
+ it 'handles an empty ToC result' do
+ input = "<p>[[<em>TOC</em>]]</p>"
+ doc = described_class.call(input)
+
+ expect(doc.to_html).to eq ''
+ end
+ end
+
describe 'result' do
def result(html)
HTML::Pipeline.new([described_class]).call(html)