diff options
author | Robert Speicher <rspeicher@gmail.com> | 2016-02-24 02:05:10 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2016-02-24 02:25:40 +0300 |
commit | bc43ad71ef2c1ab6cf56d94ac93df0bdc0e2b741 (patch) | |
tree | 1bc743f62ccd30593e430180dfa48c821f7940a2 /spec/lib/banzai/filter/gollum_tags_filter_spec.rb | |
parent | 9f80118e05e68743d95a83742a1d0a06bba3039c (diff) |
Replace Gollum `[[_TOC_]]` tag with result of TableOfContentsFilter
Closes #2494
Diffstat (limited to 'spec/lib/banzai/filter/gollum_tags_filter_spec.rb')
-rw-r--r-- | spec/lib/banzai/filter/gollum_tags_filter_spec.rb | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/spec/lib/banzai/filter/gollum_tags_filter_spec.rb b/spec/lib/banzai/filter/gollum_tags_filter_spec.rb index 38baa819957..11cc290d6d0 100644 --- a/spec/lib/banzai/filter/gollum_tags_filter_spec.rb +++ b/spec/lib/banzai/filter/gollum_tags_filter_spec.rb @@ -86,4 +86,56 @@ describe Banzai::Filter::GollumTagsFilter, lib: true do expect(doc.at_css('a')['href']).to eq 'wiki-slug' end end + + context 'table of contents' do + let(:pipeline) { Banzai::Pipeline[:wiki] } + + it 'replaces the tag with the TableOfContentsFilter result' do + markdown = <<-MD.strip_heredoc + [[_TOC_]] + + ## Header + + Foo + MD + + result = pipeline.call(markdown, project_wiki: project_wiki, project: project) + + aggregate_failures do + expect(result[:output].text).not_to include '[[_TOC_]]' + expect(result[:output].text).not_to include '[[' + expect(result[:output].to_html).to include(result[:toc]) + end + end + + it 'is case-sensitive' do + markdown = <<-MD.strip_heredoc + [[_toc_]] + + # Header 1 + + Foo + MD + + output = pipeline.to_html(markdown, project_wiki: project_wiki, project: project) + + expect(output).to include('[[<em>toc</em>]]') + end + + it 'handles an empty pipeline result' do + # No Markdown headers in this doc, so `result[:toc]` will be empty + markdown = <<-MD.strip_heredoc + [[_TOC_]] + + Foo + MD + + output = pipeline.to_html(markdown, project_wiki: project_wiki, project: project) + + aggregate_failures do + expect(output).not_to include('<ul>') + expect(output).to include('[[<em>TOC</em>]]') + end + end + end end |