emoji-picker-element/test/spec/picker/custom.test.js
Nolan Lawson f6f5d93780
chore: use @rollup/plugin-strip to remove console.log and perf marks/measures (#136)
* fix: use @rollup/plugin-strip

* fix: progress

* test: fix test

* fix: fixup
2021-05-31 08:45:59 -07:00

38 lines
1.2 KiB
JavaScript

import { ALL_EMOJI, basicBeforeEach, tick } from '../shared'
import { groups } from '../../../src/picker/groups'
import Picker from '../../../src/picker/PickerElement'
import { getAllByRole, getByRole, waitFor } from '@testing-library/dom'
describe('Custom emojis tests', () => {
beforeEach(basicBeforeEach)
test('Setting custom emoji shows the proper first page', async () => {
const picker = new Picker({
locale: 'en',
dataSource: ALL_EMOJI
})
picker.customEmoji = [
{
name: 'monkey',
shortcodes: ['monkey'],
url: 'monkey.png'
}
]
document.body.appendChild(picker)
const container = picker.shadowRoot.querySelector('.picker')
await waitFor(() => expect(getAllByRole(container, 'tab')).toHaveLength(groups.length + 1))
// We actually have to sleep here, because we want to test for a race condition where the
// custom emoji show first, but then are replaced by the non-custom emoji
// https://github.com/nolanlawson/emoji-picker-element/issues/84
await tick(50)
await waitFor(() => expect(getByRole(container, 'menuitem', { name: 'monkey' })).toBeVisible())
document.body.removeChild(picker)
await tick(20)
})
})