Improve performance when rendering many emoji

This commit is contained in:
Evan Hahn 2021-08-30 11:39:03 -05:00 committed by GitHub
parent 6f242eca57
commit 7f50fcdb54
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 17 deletions

View file

@ -28,25 +28,15 @@ describe('emoji', () => {
{ type: 'emoji', value: '😛' },
{ type: 'text', value: 'world' },
{ type: 'emoji', value: '😎' },
{ type: 'text', value: '' },
{ type: 'emoji', value: '😛' },
{ type: 'text', value: '!' },
]);
});
it('should return empty string after split at the end', () => {
assert.deepStrictEqual(splitByEmoji('hello😛'), [
{ type: 'text', value: 'hello' },
{ type: 'emoji', value: '😛' },
{ type: 'text', value: '' },
]);
});
it('should return empty string before the split at the start', () => {
assert.deepStrictEqual(splitByEmoji('😛hello'), [
{ type: 'text', value: '' },
{ type: 'emoji', value: '😛' },
{ type: 'text', value: 'hello' },
it('returns emojis as text after 5,000 emojis are found', () => {
assert.deepStrictEqual(splitByEmoji('💬'.repeat(5002)), [
...Array(5000).fill({ type: 'emoji', value: '💬' }),
{ type: 'text', value: '💬💬' },
]);
});
});