# frozen_string_literal: true require 'rails_helper' require 'pretty_text' describe PrettyText do let(:post) { Fabricate(:post) } it "supports details tag" do cooked_html = <<~HTML
foo

bar

HTML expect(cooked_html).to match_html(cooked_html) expect(PrettyText.cook("[details=foo]\nbar\n[/details]")).to match_html(cooked_html) end it "deletes elided content" do cooked_html = PrettyText.cook("Hello World\n\n
42
") mail_html = "

Hello World

\n(click for more details)" expect(PrettyText.format_for_email(cooked_html)).to match_html(mail_html) end it 'can replace spoilers in emails' do md = PrettyText.cook(<<~EOF) hello [details="Summary"] world [/details] EOF md = PrettyText.format_for_email(md, post) html = "

hello

\n\nSummary (click for more details)" expect(md).to eq(html) end it 'escapes summary text' do md = PrettyText.cook(<<~EOF) [details=""] [/details] EOF md = PrettyText.format_for_email(md, post) expect(md).not_to include('