emoji-mart-lazyload/spec/emoji-index-spec.js

45 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-04-30 01:57:52 +00:00
import emojiIndex from '../src/utils/emoji-index/emoji-index'
describe('#emojiIndex', () => {
describe('search', function() {
it('should work', () => {
2017-10-07 04:02:02 +00:00
expect(emojiIndex.search('pineapple')).toEqual([
{
id: 'pineapple',
name: 'Pineapple',
colons: ':pineapple:',
emoticons: [],
unified: '1f34d',
skin: null,
native: '🍍',
},
])
})
2017-02-17 14:47:14 +00:00
it('should filter only emojis we care about, exclude pineapple', () => {
2018-03-27 18:51:26 +00:00
let emojisToShowFilter = (data) => {
2017-11-09 06:41:57 +00:00
data.unified !== '1F34D'
}
2017-10-07 04:02:02 +00:00
expect(
2018-03-27 18:51:26 +00:00
emojiIndex.search('apple', { emojisToShowFilter }).map((obj) => obj.id),
2017-10-07 04:02:02 +00:00
).not.toContain('pineapple')
})
it('can include/exclude categories', () => {
2017-10-07 04:02:02 +00:00
expect(emojiIndex.search('flag', { include: ['people'] })).toEqual([])
})
it('can search for thinking_face', () => {
2018-03-27 18:51:26 +00:00
expect(emojiIndex.search('thinking_fac').map((x) => x.id)).toEqual([
2017-10-07 04:02:02 +00:00
'thinking_face',
])
})
it('can search for woman-facepalming', () => {
2018-03-27 18:51:26 +00:00
expect(emojiIndex.search('woman-facep').map((x) => x.id)).toEqual([
2017-10-07 04:02:02 +00:00
'woman-facepalming',
])
})
2017-10-07 04:02:02 +00:00
})
})