test: make tests more resilient (#175)

This commit is contained in:
Nolan Lawson 2021-07-10 17:26:35 -07:00 committed by GitHub
parent 7a2e2c141a
commit abc057e640
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 8 deletions

View File

@ -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)
})
@ -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', () => {
@ -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())

View File

@ -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)
@ -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)

View File

@ -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)
@ -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())