[Glitch] Emoji: Cleanup new code

Port 0c64e7f75e to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Echo
2025-10-14 11:36:25 +02:00
committed by Claire
parent a7f207604a
commit 8d1e67b6b2
14 changed files with 327 additions and 657 deletions

View File

@@ -1,35 +1,31 @@
import {
stringHasAnyEmoji,
stringHasCustomEmoji,
stringHasUnicodeEmoji,
stringHasUnicodeFlags,
} from './utils';
import { isCustomEmoji, isUnicodeEmoji, stringHasUnicodeFlags } from './utils';
describe('stringHasUnicodeEmoji', () => {
describe('isUnicodeEmoji', () => {
test.concurrent.for([
['only text', false],
['text with non-emoji symbols ™©', false],
['text with emoji 😀', true],
['multiple emojis 😀😃😄', true],
['emoji with skin tone 👍🏽', true],
['emoji with ZWJ 👩‍❤️‍👨', true],
['emoji with variation selector ✊️', true],
['emoji with keycap 1⃣', true],
['emoji with flags 🇺🇸', true],
['emoji with regional indicators 🇦🇺', true],
['emoji with gender 👩‍⚕️', true],
['emoji with family 👨‍👩‍👧‍👦', true],
['emoji with zero width joiner 👩‍🔬', true],
['emoji with non-BMP codepoint 🧑‍🚀', true],
['emoji with combining marks 👨‍👩‍👧‍👦', true],
['emoji with enclosing keycap #️⃣', true],
['emoji with no visible glyph \u200D', false],
] as const)(
'stringHasUnicodeEmoji has emojis in "%s": %o',
([text, expected], { expect }) => {
expect(stringHasUnicodeEmoji(text)).toBe(expected);
},
);
['😊', true],
['🇿🇼', true],
['🏴‍☠️', true],
['🏳️‍🌈', true],
['foo', false],
[':smile:', false],
['😊foo', false],
] as const)('isUnicodeEmoji("%s") is %o', ([input, expected], { expect }) => {
expect(isUnicodeEmoji(input)).toBe(expected);
});
});
describe('isCustomEmoji', () => {
test.concurrent.for([
[':smile:', true],
[':smile_123:', true],
[':SMILE:', true],
['😊', false],
['foo', false],
[':smile', false],
['smile:', false],
] as const)('isCustomEmoji("%s") is %o', ([input, expected], { expect }) => {
expect(isCustomEmoji(input)).toBe(expected);
});
});
describe('stringHasUnicodeFlags', () => {
@@ -51,27 +47,3 @@ describe('stringHasUnicodeFlags', () => {
},
);
});
describe('stringHasCustomEmoji', () => {
test('string with custom emoji returns true', () => {
expect(stringHasCustomEmoji(':custom: :test:')).toBeTruthy();
});
test('string without custom emoji returns false', () => {
expect(stringHasCustomEmoji('🏳️‍🌈 :🏳️‍🌈: text ™')).toBeFalsy();
});
});
describe('stringHasAnyEmoji', () => {
test('string without any emoji or characters', () => {
expect(stringHasAnyEmoji('normal text. 12356?!')).toBeFalsy();
});
test('string with non-emoji characters', () => {
expect(stringHasAnyEmoji('™©')).toBeFalsy();
});
test('has unicode emoji', () => {
expect(stringHasAnyEmoji('🏳️‍🌈🔥🇸🇹 👩‍🔬')).toBeTruthy();
});
test('has custom emoji', () => {
expect(stringHasAnyEmoji(':test: :custom:')).toBeTruthy();
});
});