Reject reactions with invalid number of graphemes

This commit is contained in:
Evan Hahn 2021-04-07 12:04:42 -05:00 committed by Josh Perez
parent 95482fbf31
commit f615b1a75f
5 changed files with 92 additions and 2 deletions

View file

@ -3,9 +3,26 @@
import { assert } from 'chai';
import { count } from '../../util/grapheme';
import { getGraphemes, count } from '../../util/grapheme';
describe('grapheme utilities', () => {
describe('getGraphemes', () => {
it('returns extended graphemes in a string', () => {
assert.deepEqual([...getGraphemes('')], []);
assert.deepEqual([...getGraphemes('hello')], [...'hello']);
assert.deepEqual(
[...getGraphemes('Bokmål')],
['B', 'o', 'k', 'm', 'å', 'l']
);
assert.deepEqual([...getGraphemes('💩💩💩')], ['💩', '💩', '💩']);
assert.deepEqual([...getGraphemes('👩‍❤️‍👩')], ['👩‍❤️‍👩']);
assert.deepEqual([...getGraphemes('👌🏽👌🏾👌🏿')], ['👌🏽', '👌🏾', '👌🏿']);
assert.deepEqual([...getGraphemes('L̷̳͔̲͝Ģ̵̮̯̤̩̙͍̬̟͉̹̘̹͍͈̮̦̰̣͟͝O̶̴̮̻̮̗͘͡!̴̷̟͓͓')], ['L̷̳͔̲͝', 'Ģ̵̮̯̤̩̙͍̬̟͉̹̘̹͍͈̮̦̰̣͟͝', 'O̶̴̮̻̮̗͘͡', '!̴̷̟͓͓']);
});
});
describe('count', () => {
it('returns the number of extended graphemes in a string (not necessarily the length)', () => {
// These tests modified [from iOS][0].