-
Notifications
You must be signed in to change notification settings - Fork 79
/
upgrade.test.js
56 lines (41 loc) · 1.51 KB
/
upgrade.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import {
basicAfterEach,
basicBeforeEach,
FR_EMOJI,
mockFrenchDataSource,
tick
} from '../shared'
import { getByRole, waitFor } from '@testing-library/dom'
describe('upgrade tests', () => {
beforeEach(async () => {
basicBeforeEach()
mockFrenchDataSource()
})
afterEach(async () => {
basicAfterEach()
})
test('setting props and attributes before upgrade', async () => {
const div = document.createElement('div')
document.body.appendChild(div)
div.innerHTML = '<emoji-picker locale="fr"></emoji-picker>'
const picker = div.querySelector('emoji-picker')
picker.dataSource = FR_EMOJI
picker.skinToneEmoji = '👍'
expect(picker.shadowRoot).toBeNull()
await tick(20)
expect(fetch).not.toHaveBeenCalled()
await import('../../../src/picker/PickerElement')
await waitFor(() => expect(getByRole(picker.shadowRoot, 'menuitem', { name: /😀/ })).toBeVisible())
const container = picker.shadowRoot
expect(fetch).toHaveBeenCalledTimes(1)
expect(fetch).toHaveBeenLastCalledWith(FR_EMOJI, undefined)
expect(getByRole(container, 'button', { name: /Choose a skin tone/ }).innerHTML).toContain('👍')
expect(picker.locale).toEqual('fr')
expect(picker.dataSource).toEqual(FR_EMOJI)
// The setter should now work as expected
picker.skinToneEmoji = '✌'
await waitFor(() => expect(getByRole(container, 'button', { name: /Choose a skin tone/ }).innerHTML).toContain('✌'))
document.body.removeChild(div)
await tick(20)
})
})