Skip to content

Commit

Permalink
fix: fix re-setting
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanlawson committed Jul 26, 2021
1 parent 5e2210a commit 813e711
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/picker/PickerElement.js
Expand Up @@ -37,6 +37,7 @@ export default class PickerElement extends HTMLElement {
for (const prop of PROPS) {
if (prop !== 'database' && Object.hasOwnProperty.call(this, prop)) {
this._ctx[prop] = this[prop]
delete this[prop]
}
}
this._dbFlush() // wait for a flush before creating the db, in case the user calls e.g. a setter or setAttribute
Expand Down
5 changes: 3 additions & 2 deletions test/spec/picker/upgrade.test.js
Expand Up @@ -40,14 +40,15 @@ describe('upgrade tests', () => {
expect(fetch).toHaveBeenCalledTimes(1)
expect(fetch).toHaveBeenLastCalledWith(FR_EMOJI, undefined)

expect(getByRole(container, 'menuitem', { name: /πŸ‘/ })).toBeVisible()
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, 'menuitem', { name: /πŸ‘/ })).toBeVisible())
await waitFor(() => expect(getByRole(container, 'button', { name: /Choose a skin tone/ }).innerHTML).toContain('✌'))

document.body.removeChild(div)
await tick(20)
Expand Down

0 comments on commit 813e711

Please sign in to comment.