discourse/plugins/chat/spec/lib/slack_compatibility_spec.rb
Roman Rizzi 0a5f548635
DEV: Move discourse-chat to the core repo. (#18776)
As part of this move, we are also renaming `discourse-chat` to `chat`.
2022-11-02 10:41:30 -03:00

34 lines
1.2 KiB
Ruby

# frozen_string_literal: true
require "rails_helper"
describe Chat::SlackCompatibility do
describe "#process_text" do
it "converts mrkdwn links to regular markdown" do
text = described_class.process_text("this is some text <https://discourse.org>")
expect(text).to eq("this is some text https://discourse.org")
end
it "converts mrkdwn links with titles to regular markdown" do
text =
described_class.process_text("this is some text <https://discourse.org|Discourse Forums>")
expect(text).to eq("this is some text [Discourse Forums](https://discourse.org)")
end
it "handles multiple links" do
text =
described_class.process_text(
"this is some text <https://discourse.org|Discourse Forums> with a second link to <https://discourse.org/team>",
)
expect(text).to eq(
"this is some text [Discourse Forums](https://discourse.org) with a second link to https://discourse.org/team",
)
end
it "converts <!here> and <!all> to our mention format" do
text = described_class.process_text("<!here> this is some important stuff <!all>")
expect(text).to eq("@here this is some important stuff @all")
end
end
end