From 39fc02bfe38445d25201fdb2fd025ded2fb0f3b4 Mon Sep 17 00:00:00 2001 From: Hinaloe Date: Sat, 23 Mar 2019 09:25:51 -0700 Subject: [PATCH 1/2] test: add test for short_names in custom emoji --- src/components/category.js | 2 +- .../picker/__tests__/nimble-picker.test.js | 35 +++++++++++++++++++ src/components/picker/nimble-picker.js | 4 ++- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/components/category.js b/src/components/category.js index 26e08b8..c67c321 100644 --- a/src/components/category.js +++ b/src/components/category.js @@ -134,7 +134,7 @@ export default class Category extends React.Component { updateDisplay(display) { var emojis = this.getEmojis() - if (!emojis) { + if (!emojis || !this.container) { return } diff --git a/src/components/picker/__tests__/nimble-picker.test.js b/src/components/picker/__tests__/nimble-picker.test.js index 81d2101..cefb891 100644 --- a/src/components/picker/__tests__/nimble-picker.test.js +++ b/src/components/picker/__tests__/nimble-picker.test.js @@ -1,5 +1,6 @@ import React from 'react' import NimblePicker from '../nimble-picker' +import NimbleEmojiIndex from '../../../utils/emoji-index/nimble-emoji-index' import renderer from 'react-test-renderer' import data from '../../../../data/apple' @@ -27,3 +28,37 @@ test('maintains category ids after it is filtered', () => { const categoriesWithIds = subject.categories.filter((category) => category.id) expect(categoriesWithIds.length).toEqual(10) }) + +test('with custom emoji and tooltip', () => { + const custom = [ + { + id: 'custom_name', + name: 'custom_name', + short_names: ['custom_name'], + text: '', + emoticons: [], + keywords: ['custom_name'], + imageUrl: 'https://example.com/emoji', + custom: true, + }, + { + id: 'custom_name2', + name: 'custom_name2', + short_names: ['custom_name2'], + text: '', + emoticons: [], + keywords: ['custom_name2'], + imageUrl: 'https://example.com/emoji', + custom: true, + }, + ] + const subject = render({ + emojiTooltip: true, + autoFocus: true, + // emojisToShowFilter: emoji => emoji.id && emoji.id.startsWith('custom'), + custom, + }) + subject.handleSearch( + new NimbleEmojiIndex(subject.data).search('custom_', { custom }), + ) +}) diff --git a/src/components/picker/nimble-picker.js b/src/components/picker/nimble-picker.js index 736e92f..4b526ec 100644 --- a/src/components/picker/nimble-picker.js +++ b/src/components/picker/nimble-picker.js @@ -355,7 +355,9 @@ export default class NimblePicker extends React.PureComponent { } this.forceUpdate() - this.scroll.scrollTop = 0 + if (this.scroll) { + this.scroll.scrollTop = 0 + } this.handleScroll() } From 7039517939bd21874597da9abd041e6ff46a3b64 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sat, 23 Mar 2019 15:06:13 -0700 Subject: [PATCH 2/2] remove code comment --- src/components/picker/__tests__/nimble-picker.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/picker/__tests__/nimble-picker.test.js b/src/components/picker/__tests__/nimble-picker.test.js index cefb891..484ddfb 100644 --- a/src/components/picker/__tests__/nimble-picker.test.js +++ b/src/components/picker/__tests__/nimble-picker.test.js @@ -55,7 +55,6 @@ test('with custom emoji and tooltip', () => { const subject = render({ emojiTooltip: true, autoFocus: true, - // emojisToShowFilter: emoji => emoji.id && emoji.id.startsWith('custom'), custom, }) subject.handleSearch(