Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions app/containers/markdown/__snapshots__/Markdown.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ exports[`Story Snapshots: Emoji should match snapshot 1`] = `
}
>

πŸ‘
πŸ‘οΈ
</Text>
</Text>
</Text>
Expand Down Expand Up @@ -1005,7 +1005,7 @@ exports[`Story Snapshots: Emoji should match snapshot 1`] = `
]
}
>
πŸ‘
πŸ‘οΈ
</Text>
<View
style={
Expand Down Expand Up @@ -7821,7 +7821,7 @@ exports[`Story Snapshots: Preview should match snapshot 1`] = `
@rocket.cat @name1 @all @here @unknown #general #unknown
</Text>
<Text
accessibilityLabel="Testing: πŸ˜ƒ πŸ‘ :marioparty:"
accessibilityLabel="Testing: πŸ˜ƒ πŸ‘οΈ :marioparty:"
numberOfLines={1}
style={
[
Expand All @@ -7842,9 +7842,9 @@ exports[`Story Snapshots: Preview should match snapshot 1`] = `
},
]
}
testID="markdown-preview-Testing: πŸ˜ƒ πŸ‘ :marioparty:"
testID="markdown-preview-Testing: πŸ˜ƒ πŸ‘οΈ :marioparty:"
>
Testing: πŸ˜ƒ πŸ‘ :marioparty:
Testing: πŸ˜ƒ πŸ‘οΈ :marioparty:
</Text>
<Text
accessibilityLabel="Fallback from new md to old"
Expand Down
39 changes: 39 additions & 0 deletions app/lib/constants/emojis/data.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { aliasesByEmojiName, emojisByCategory, shortnameToUnicodeMap } from './data';
import { emojis } from './emojis';
import { legacyShortnameToUnicodeMap } from './legacyShortnames';

describe('emoji data', () => {
it('resolves every listed emoji to a unicode character', () => {
const unresolved = emojis.filter(name => !shortnameToUnicodeMap[`:${name}:`]);
expect(unresolved).toEqual([]);
});

it('lists every emoji exactly once', () => {
expect(emojis.length).toBe(new Set(emojis).size);
});

it('keys aliases by a listed emoji name', () => {
const listed = new Set(emojis);
expect(Object.keys(aliasesByEmojiName).filter(name => !listed.has(name))).toEqual([]);
});

it('resolves every alias to the same emoji as the name it belongs to', () => {
Comment thread
OtavioStasiak marked this conversation as resolved.
const mismatched = Object.keys(aliasesByEmojiName).filter(name =>
aliasesByEmojiName[name].some(alias => {
const unicode = shortnameToUnicodeMap[`:${alias}:`] ?? legacyShortnameToUnicodeMap[`:${alias}:`];
return !unicode;
})
);
expect(mismatched).toEqual([]);
});
Comment thread
OtavioStasiak marked this conversation as resolved.

it('has no category with an empty emoji list', () => {
expect(
Object.keys(emojisByCategory).filter(key => emojisByCategory[key as keyof typeof emojisByCategory].length === 0)
).toEqual([]);
});

it('keeps legacy shortnames out of the current map', () => {
expect(Object.keys(legacyShortnameToUnicodeMap).filter(key => key in shortnameToUnicodeMap)).toEqual([]);
});
});
Loading
Loading