Skip to content

Commit

Permalink
test: update test to run timers
Browse files Browse the repository at this point in the history
  • Loading branch information
joshblack committed May 9, 2024
1 parent 7f18c34 commit 6e0e38f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 88 deletions.
85 changes: 3 additions & 82 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@ import {render} from '@testing-library/react'
import React from 'react'
import {SelectPanel} from '../'

jest.useFakeTimers()

describe('SelectPanel.Loading', () => {
it('should announce children as a polite message', () => {
render(<SelectPanel.Loading>test</SelectPanel.Loading>)
it('should announce a default message when no children are provided', () => {
render(<SelectPanel.Loading />)

const liveRegion = document.querySelector('live-region')!
expect(liveRegion.getMessage('polite')).toBe('test')
jest.runAllTimers()
expect(liveRegion.getMessage('polite')).toBe('Fetching items...')
})

it('should announce a default message when no children are provided', () => {
render(<SelectPanel.Loading />)
it('should announce children as a polite message', () => {
render(<SelectPanel.Loading>test</SelectPanel.Loading>)

const liveRegion = document.querySelector('live-region')!
expect(liveRegion.getMessage('polite')).toBe('Fetching items...')
jest.runAllTimers()
expect(liveRegion.getMessage('polite')).toBe('test')
})
})

0 comments on commit 6e0e38f

Please sign in to comment.