debian-mirror-gitlab/spec/lib/banzai/filter/table_of_contents_tag_filter_spec.rb

48 lines
1.1 KiB
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Banzai::Filter::TableOfContentsTagFilter do
2020-03-13 15:44:24 +05:30
include FilterSpecHelper
context 'table of contents' do
2021-10-27 15:23:28 +05:30
shared_examples 'table of contents tag' do
it 'replaces toc tag with ToC result' do
doc = filter(html, {}, { toc: "FOO" })
2020-03-13 15:44:24 +05:30
2021-10-27 15:23:28 +05:30
expect(doc.to_html).to eq("FOO")
end
2020-03-13 15:44:24 +05:30
2021-10-27 15:23:28 +05:30
it 'handles an empty ToC result' do
doc = filter(html)
expect(doc.to_html).to eq ''
end
end
context '[[_TOC_]] as tag' do
it_behaves_like 'table of contents tag' do
let(:html) { '<p>[[<em>TOC</em>]]</p>' }
end
2020-03-13 15:44:24 +05:30
end
2021-10-27 15:23:28 +05:30
context '[[_toc_]] as tag' do
it_behaves_like 'table of contents tag' do
let(:html) { '<p>[[<em>toc</em>]]</p>' }
end
end
context '[TOC] as tag' do
it_behaves_like 'table of contents tag' do
let(:html) { '<p>[TOC]</p>' }
end
end
2020-03-13 15:44:24 +05:30
2021-10-27 15:23:28 +05:30
context '[toc] as tag' do
it_behaves_like 'table of contents tag' do
let(:html) { '<p>[toc]</p>' }
end
2020-03-13 15:44:24 +05:30
end
end
end