# frozen_string_literal: true require 'spec_helper' RSpec.describe Banzai::Filter::TableOfContentsTagFilter do include FilterSpecHelper context 'table of contents' do shared_examples 'table of contents tag' do it 'replaces toc tag with ToC result' do doc = filter(html, {}, { toc: "FOO" }) expect(doc.to_html).to eq("FOO") end 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) { '

[[TOC]]

' } end end context '[[_toc_]] as tag' do it_behaves_like 'table of contents tag' do let(:html) { '

[[toc]]

' } end end context '[TOC] as tag' do it_behaves_like 'table of contents tag' do let(:html) { '

[TOC]

' } end end context '[toc] as tag' do it_behaves_like 'table of contents tag' do let(:html) { '

[toc]

' } end end end end