Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewPrigorshnev committed Sep 7, 2023
1 parent 6b76aa7 commit 80c105d
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion app/assets/javascripts/discourse/tests/unit/lib/text-test.js
Expand Up @@ -45,7 +45,7 @@ module("Unit | Utility | text | parseMentions", function () {
test("parses mentions from markdown", async function (assert) {
const markdown = "Hey @user1, @user2, @group1, @group2, @here, @all";
const mentions = await parseMentions(markdown);
assert.equal(mentions, [
assert.deepEqual(mentions, [
"user1",
"user2",
"group1",
Expand All @@ -54,4 +54,22 @@ module("Unit | Utility | text | parseMentions", function () {
"all",
]);
});

test("ignores duplicated mentions", async function (assert) {
const markdown = "Hey @john, @john, @john, @john";
const mentions = await parseMentions(markdown);
assert.deepEqual(mentions, ["john"]);
});

test("ignores mentions in codeblocks", async function (assert) {
const markdown = `Hey
\`\`\`
def foo
@bar = true
end
\`\`\`
`;
const mentions = await parseMentions(markdown);
assert.equal(mentions.length, 0);
});
});

0 comments on commit 80c105d

Please sign in to comment.