# frozen_string_literal: true require "rails_helper" describe MarkdownHelper, type: :helper do before do stub_const("APP_CONFIG", { "hostname" => "example.com", "https" => true, "items_per_page" => 5, "allowed_hosts" => [ "twitter.com" ], },) end describe "#markdown" do it "should return the expected text" do expect(markdown("**Strong text**")).to eq("
Strong text
") end it "should transform mentions into links" do expect(markdown("@jake_weary")).to eq('') end it "should escape text in links" do expect(markdown("[It's a link](https://example.com)")).to eq('') expect(markdown("[It's >a link](https://example.com)")).to eq('') end it "should escape HTML tags" do expect(markdown("I'mI'm <h1>a test</h1>
") end it "should turn line breaks intoSome
\ntext
https://twitter.com/retrospring
') end it "should link untrusted links with the linkfilter" do expect(question_markdown("https://rrerr.net")).to eq('') end it "should not process any markup aside of links" do expect(question_markdown("**your account has been disabled**, [click here to enable it again](https://evil.example.com)")).to eq('your account has been disabled, https://evil.example.com
') expect(question_markdown("> the important question is: will it blend?")).to eq("the important question is: will it blend?
") end it "should not raise an exception if an invalid link is processed" do expect { question_markdown("https://example.com/example.質問") }.not_to raise_error end it "should not process invalid links" do expect(question_markdown("https://example.com/example.質問")).to eq("https://example.com/example.質問
") end it "should turn line breaks intoSome
\ntext
Strong text
") end end describe "#strip_markdown_io" do it "should return the expected text" do expect(strip_markdown_io("spec/fixtures/markdown/io.md")).to eq("Strong text") end end describe "#twitter_markdown_io" do let(:user) { FactoryBot.create(:user) } it "should return the expected text" do expect(twitter_markdown_io("spec/fixtures/markdown/twitter.md")).to eq("test") end end describe "#raw_markdown_io" do it "should return the expected text" do expect(raw_markdown_io("spec/fixtures/markdown/test.md")).to eq("