Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add test for short_names in custom emoji #323

Merged
merged 2 commits into from
Mar 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/components/category.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export default class Category extends React.Component {
updateDisplay(display) {
var emojis = this.getEmojis()

if (!emojis) {
if (!emojis || !this.container) {
return
}

Expand Down
34 changes: 34 additions & 0 deletions src/components/picker/__tests__/nimble-picker.test.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -27,3 +28,36 @@ 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,
custom,
})
subject.handleSearch(
new NimbleEmojiIndex(subject.data).search('custom_', { custom }),
)
})
4 changes: 3 additions & 1 deletion src/components/picker/nimble-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down