mirror of
https://github.com/block/buzz.git
synced 2026-11-26 03:01:38 +00:00
Fix emoji message rendering (#938)
Signed-off-by: Wes <wesbillman@users.noreply.github.com> Co-authored-by: Pinky <44b8e82baa6e0e254e0208d68f335c283c94e7b78dd1fa10d5a49d3f13dd0435@sprout-oss.stage.blox.sqprod.co>
This commit is contained in:
36
desktop/src/shared/lib/emojiOnly.test.mjs
Normal file
36
desktop/src/shared/lib/emojiOnly.test.mjs
Normal file
@@ -0,0 +1,36 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import { isEmojiOnlyMessage } from "./emojiOnly.ts";
|
||||
|
||||
const CUSTOM_EMOJI = [
|
||||
{ shortcode: "sprout", url: "https://relay/sprout.png" },
|
||||
{ shortcode: "party_parrot", url: "https://relay/parrot.gif" },
|
||||
];
|
||||
|
||||
test("detects unicode emoji-only messages", () => {
|
||||
assert.equal(isEmojiOnlyMessage("😀", CUSTOM_EMOJI), true);
|
||||
assert.equal(isEmojiOnlyMessage("😀 👍🏽\n❤️", CUSTOM_EMOJI), true);
|
||||
assert.equal(isEmojiOnlyMessage("🏳️🌈 👨👩👧👦", CUSTOM_EMOJI), true);
|
||||
});
|
||||
|
||||
test("detects known custom emoji-only shortcode messages", () => {
|
||||
assert.equal(isEmojiOnlyMessage(":sprout:", CUSTOM_EMOJI), true);
|
||||
assert.equal(
|
||||
isEmojiOnlyMessage(":sprout: :party_parrot:", CUSTOM_EMOJI),
|
||||
true,
|
||||
);
|
||||
assert.equal(isEmojiOnlyMessage(":Sprout:", CUSTOM_EMOJI), true);
|
||||
});
|
||||
|
||||
test("allows mixed unicode and custom emoji", () => {
|
||||
assert.equal(isEmojiOnlyMessage("😀 :sprout: ❤️", CUSTOM_EMOJI), true);
|
||||
});
|
||||
|
||||
test("rejects prose, markdown, and unknown shortcodes", () => {
|
||||
assert.equal(isEmojiOnlyMessage("hello 😀", CUSTOM_EMOJI), false);
|
||||
assert.equal(isEmojiOnlyMessage("😀!", CUSTOM_EMOJI), false);
|
||||
assert.equal(isEmojiOnlyMessage("**😀**", CUSTOM_EMOJI), false);
|
||||
assert.equal(isEmojiOnlyMessage(":unknown:", CUSTOM_EMOJI), false);
|
||||
assert.equal(isEmojiOnlyMessage("", CUSTOM_EMOJI), false);
|
||||
});
|
||||
Reference in New Issue
Block a user