Skip to content

Commit

Permalink
Add failing emoji test
Browse files Browse the repository at this point in the history
  • Loading branch information
tassoevan committed Sep 12, 2024
1 parent 276185e commit fc151bd
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 80 deletions.
164 changes: 84 additions & 80 deletions packages/message-parser/tests/emoji.test.ts
Original file line number Diff line number Diff line change
@@ -1,90 +1,94 @@
import { parse } from '../src';
import { emoji, bigEmoji, paragraph, plain, emojiUnicode } from '../src/utils';

test.each([
[':smile: asd', [paragraph([emoji('smile'), plain(' asd')])]],
['text:inner:outer', [paragraph([plain('text:inner:outer')])]],
['10:20:30', [paragraph([plain('10:20:30')])]],
['10:20:30:', [paragraph([plain('10:20:30:')])]],
['":smile:"', [paragraph([plain('":smile:"')])]],
['":smile: "', [paragraph([plain('":smile: "')])]],
['" :smile: "', [paragraph([plain('" '), emoji('smile'), plain(' "')])]],
[
`:smile:
describe('short-code emojis', () => {
test.each([
[':smile: asd', [paragraph([emoji('smile'), plain(' asd')])]],
['text:inner:outer', [paragraph([plain('text:inner:outer')])]],
['10:20:30', [paragraph([plain('10:20:30')])]],
['10:20:30:', [paragraph([plain('10:20:30:')])]],
['":smile:"', [paragraph([plain('":smile:"')])]],
['":smile: "', [paragraph([plain('":smile: "')])]],
['" :smile: "', [paragraph([plain('" '), emoji('smile'), plain(' "')])]],
[
`:smile:
:smile:
`,
[bigEmoji([emoji('smile'), emoji('smile')])],
],
[
'asdas :smile: asd',
[paragraph([plain('asdas '), emoji('smile'), plain(' asd')])],
],
[
'normal emojis :smile: :smile: :smile:',
[bigEmoji([emoji('smile'), emoji('smile')])],
],
[
'asdas :smile: asd',
[paragraph([plain('asdas '), emoji('smile'), plain(' asd')])],
],
[
'normal emojis :smile: :smile: :smile:',
[
paragraph([
plain('normal emojis '),
emoji('smile'),
plain(' '),
emoji('smile'),
plain(' '),
emoji('smile'),
]),
],
],
[
':smile::smile::smile:',
[bigEmoji([emoji('smile'), emoji('smile'), emoji('smile')])],
],
[
paragraph([
plain('normal emojis '),
emoji('smile'),
plain(' '),
emoji('smile'),
plain(' '),
emoji('smile'),
]),
' :smile::smile::smile: ',
[bigEmoji([emoji('smile'), emoji('smile'), emoji('smile')])],
],
],
[
':smile::smile::smile:',
[bigEmoji([emoji('smile'), emoji('smile'), emoji('smile')])],
],
[
' :smile::smile::smile: ',
[bigEmoji([emoji('smile'), emoji('smile'), emoji('smile')])],
],
[
'\n :smile::smile::smile: \n',
[bigEmoji([emoji('smile'), emoji('smile'), emoji('smile')])],
],
[
':smile: :smile: :smile:',
[bigEmoji([emoji('smile'), emoji('smile'), emoji('smile')])],
],
[':smile::smile:', [bigEmoji([emoji('smile'), emoji('smile')])]],
[':smile:', [bigEmoji([emoji('smile')])]],
['Hi :+1:', [paragraph([plain('Hi '), emoji('+1')])]],
['Hi :+1_tone4:', [paragraph([plain('Hi '), emoji('+1_tone4')])]],
])('parses %p', (input, output) => {
expect(parse(input)).toMatchObject(output);
[
'\n :smile::smile::smile: \n',
[bigEmoji([emoji('smile'), emoji('smile'), emoji('smile')])],
],
[
':smile: :smile: :smile:',
[bigEmoji([emoji('smile'), emoji('smile'), emoji('smile')])],
],
[':smile::smile:', [bigEmoji([emoji('smile'), emoji('smile')])]],
[':smile:', [bigEmoji([emoji('smile')])]],
['Hi :+1:', [paragraph([plain('Hi '), emoji('+1')])]],
['Hi :+1_tone4:', [paragraph([plain('Hi '), emoji('+1_tone4')])]],
[':+1:?', [paragraph([emoji('+1'), plain('?')])]],
])('parses %p', (input, output) => {
expect(parse(input)).toMatchObject(output);
});
});

// Tests for unicode emojis
test.each([
['😀', [bigEmoji([emojiUnicode('😀')])]],
['😃', [bigEmoji([emojiUnicode('😃')])]],
['🥵', [bigEmoji([emojiUnicode('🥵')])]],
['🧿', [bigEmoji([emojiUnicode('🧿')])]],
['🐶', [bigEmoji([emojiUnicode('🐶')])]],
['🍏', [bigEmoji([emojiUnicode('🍏')])]],
['⚽', [bigEmoji([emojiUnicode('⚽')])]],
['⚽️', [bigEmoji([emojiUnicode('⚽️')])]],
['👨‍👩‍👧‍👦', [bigEmoji([emojiUnicode('👨‍👩‍👧‍👦')])]],
['🚗', [bigEmoji([emojiUnicode('🚗')])]],
['⌚️', [bigEmoji([emojiUnicode('⌚️')])]],
['❤️', [bigEmoji([emojiUnicode('❤️')])]],
['🏳️', [bigEmoji([emojiUnicode('🏳️')])]],
['🧑🏾‍💻', [bigEmoji([emojiUnicode('🧑🏾‍💻')])]],
['🧑🏾‍💻🧑🏾‍💻', [bigEmoji([emojiUnicode('🧑🏾‍💻'), emojiUnicode('🧑🏾‍💻')])]],
[
'🧑🏾‍💻🧑🏾‍💻🧑🏾‍💻',
[bigEmoji([emojiUnicode('🧑🏾‍💻'), emojiUnicode('🧑🏾‍💻'), emojiUnicode('🧑🏾‍💻')])],
],
['👆🏽', [bigEmoji([emojiUnicode('👆🏽')])]],
['👆🏽👆🏽', [bigEmoji([emojiUnicode('👆🏽'), emojiUnicode('👆🏽')])]],
[
'👆🏽👆🏽👆🏽',
[bigEmoji([emojiUnicode('👆🏽'), emojiUnicode('👆🏽'), emojiUnicode('👆🏽')])],
],
['👆🏺', [bigEmoji([emojiUnicode('👆'), emojiUnicode('🏺')])]],
['Hi 👍', [paragraph([plain('Hi '), emojiUnicode('👍')])]],
])('parses %p', (input, output) => {
expect(parse(input)).toMatchObject(output);
describe('unicode emojis', () => {
test.each([
['😀', [bigEmoji([emojiUnicode('😀')])]],
['😃', [bigEmoji([emojiUnicode('😃')])]],
['🥵', [bigEmoji([emojiUnicode('🥵')])]],
['🧿', [bigEmoji([emojiUnicode('🧿')])]],
['🐶', [bigEmoji([emojiUnicode('🐶')])]],
['🍏', [bigEmoji([emojiUnicode('🍏')])]],
['⚽', [bigEmoji([emojiUnicode('⚽')])]],
['⚽️', [bigEmoji([emojiUnicode('⚽️')])]],
['👨‍👩‍👧‍👦', [bigEmoji([emojiUnicode('👨‍👩‍👧‍👦')])]],
['🚗', [bigEmoji([emojiUnicode('🚗')])]],
['⌚️', [bigEmoji([emojiUnicode('⌚️')])]],
['❤️', [bigEmoji([emojiUnicode('❤️')])]],
['🏳️', [bigEmoji([emojiUnicode('🏳️')])]],
['🧑🏾‍💻', [bigEmoji([emojiUnicode('🧑🏾‍💻')])]],
['🧑🏾‍💻🧑🏾‍💻', [bigEmoji([emojiUnicode('🧑🏾‍💻'), emojiUnicode('🧑🏾‍💻')])]],
[
'🧑🏾‍💻🧑🏾‍💻🧑🏾‍💻',
[bigEmoji([emojiUnicode('🧑🏾‍💻'), emojiUnicode('🧑🏾‍💻'), emojiUnicode('🧑🏾‍💻')])],
],
['👆🏽', [bigEmoji([emojiUnicode('👆🏽')])]],
['👆🏽👆🏽', [bigEmoji([emojiUnicode('👆🏽'), emojiUnicode('👆🏽')])]],
[
'👆🏽👆🏽👆🏽',
[bigEmoji([emojiUnicode('👆🏽'), emojiUnicode('👆🏽'), emojiUnicode('👆🏽')])],
],
['👆🏺', [bigEmoji([emojiUnicode('👆'), emojiUnicode('🏺')])]],
['Hi 👍', [paragraph([plain('Hi '), emojiUnicode('👍')])]],
])('parses %p', (input, output) => {
expect(parse(input)).toMatchObject(output);
});
});
18 changes: 18 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8992,6 +8992,7 @@ __metadata:
"@storybook/react": ~6.5.16
"@storybook/testing-library": ~0.0.13
"@testing-library/react": ~16.0.0
"@types/dompurify": ^3.0.5
"@types/jest": ~29.5.12
"@types/katex": ~0.16.5
"@types/react": ~17.0.69
Expand All @@ -9000,6 +9001,7 @@ __metadata:
"@typescript-eslint/parser": ~5.60.1
babel-loader: ^8.3.0
date-fns: ^3.3.1
dompurify: ^3.1.6
eslint: ~8.45.0
eslint-plugin-anti-trojan-source: ~1.1.1
eslint-plugin-react: ~7.32.2
Expand Down Expand Up @@ -13382,6 +13384,15 @@ __metadata:
languageName: node
linkType: hard

"@types/dompurify@npm:^3.0.5":
version: 3.0.5
resolution: "@types/dompurify@npm:3.0.5"
dependencies:
"@types/trusted-types": "*"
checksum: ffc34eca6a4536e1c8c16a47cce2623c5a118a9785492e71230052d92933ff096d14326ff449031e8dfaac509413222372d8f2b28786a13159de6241df716185
languageName: node
linkType: hard

"@types/ejson@npm:^2.2.1":
version: 2.2.1
resolution: "@types/ejson@npm:2.2.1"
Expand Down Expand Up @@ -21370,6 +21381,13 @@ __metadata:
languageName: node
linkType: hard

"dompurify@npm:^3.1.6":
version: 3.1.6
resolution: "dompurify@npm:3.1.6"
checksum: cc4fc4ccd9261fbceb2a1627a985c70af231274a26ddd3f643fd0616a0a44099bd9e4480940ce3655612063be4a1fe9f5e9309967526f8c0a99f931602323866
languageName: node
linkType: hard

"domutils@npm:^1.7.0":
version: 1.7.0
resolution: "domutils@npm:1.7.0"
Expand Down

0 comments on commit fc151bd

Please sign in to comment.