Skip to content

Commit

Permalink
test: make tests more resilient (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanlawson committed Jul 11, 2021
1 parent 7a2e2c1 commit abc057e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions test/spec/picker/element.test.js
Expand Up @@ -30,7 +30,7 @@ describe('element tests', () => {
basicBeforeEach()
mockFrenchDataSource()
picker = new Picker({ dataSource: ALL_EMOJI, locale: 'en' })
container = picker.shadowRoot.querySelector('.picker')
container = picker.shadowRoot
document.body.appendChild(picker)
await tick(20)
})
Expand Down Expand Up @@ -75,9 +75,9 @@ describe('element tests', () => {
expect(getByRole(container, 'button', { name: /Choose a skin tone/ }).innerHTML)
.toContain(DEFAULT_SKIN_TONE_EMOJI)
picker.skinToneEmoji = '👇'
expect(getByRole(container, 'button', { name: /Choose a skin tone/ }).innerHTML).toContain('👇')
await waitFor(() => expect(getByRole(container, 'button', { name: /Choose a skin tone/ }).innerHTML).toContain('👇'))
picker.skinToneEmoji = '👋'
expect(getByRole(container, 'button', { name: /Choose a skin tone/ }).innerHTML).toContain('👋')
await waitFor(() => expect(getByRole(container, 'button', { name: /Choose a skin tone/ }).innerHTML).toContain('👋'))
})

test('can get the locale/dataSource', () => {
Expand All @@ -97,7 +97,7 @@ describe('element tests', () => {
test('has a default locale/dataSource', async () => {
const picker = new Picker()
document.body.appendChild(picker)
const container = picker.shadowRoot.querySelector('.picker')
const container = picker.shadowRoot
await tick(20)

await waitFor(() => expect(getByRole(container, 'menuitem', { name: /😀/ })).toBeVisible())
Expand Down
4 changes: 2 additions & 2 deletions test/spec/picker/errors.test.js
Expand Up @@ -28,7 +28,7 @@ describe('errors', () => {
fetch.head(dataSource, { body: null, status: 500 })

const picker = new Picker({ dataSource })
const container = picker.shadowRoot.querySelector('.picker')
const container = picker.shadowRoot
document.body.appendChild(picker)

await tick(20)
Expand All @@ -51,7 +51,7 @@ describe('errors', () => {
{ delay: 1500 })

const picker = new Picker({ dataSource })
const container = picker.shadowRoot.querySelector('.picker')
const container = picker.shadowRoot
document.body.appendChild(picker)
await tick(20)

Expand Down
4 changes: 2 additions & 2 deletions test/spec/picker/lifecycle.test.js
Expand Up @@ -10,7 +10,7 @@ describe('lifecycle', () => {
test('can remove and re-append custom element', async () => {
mockDefaultDataSource()
const picker = new Picker()
const container = picker.shadowRoot.querySelector('.picker')
const container = picker.shadowRoot

document.body.appendChild(picker)

Expand All @@ -37,7 +37,7 @@ describe('lifecycle', () => {
mockDefaultDataSource()
const picker = new Picker()
document.body.appendChild(picker)
const container = picker.shadowRoot.querySelector('.picker')
const container = picker.shadowRoot

await waitFor(() => expect(getByRole(container, 'menuitem', { name: /😀/ })).toBeVisible())

Expand Down

0 comments on commit abc057e

Please sign in to comment.