Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/ui-alerts/src/Alert/__tests__/Alert.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('<Alert />', () => {
)
const closeButton = screen.getByRole('button')

userEvent.click(closeButton)
await userEvent.click(closeButton)

await waitFor(() => {
expect(onDismiss).toHaveBeenCalled()
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-calendar/src/Calendar/__tests__/Day.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ describe('Day', () => {

const day = container.querySelector('[class*="-calendarDay"]')!

userEvent.type(day, '{enter}')
await userEvent.type(day, '{enter}')

await waitFor(() => {
const args = onKeyDown.mock.calls[0][1]
Expand All @@ -258,7 +258,7 @@ describe('Day', () => {
)
const day = container.querySelector('[class*="-calendarDay"]')!

userEvent.click(day)
await userEvent.click(day)

await waitFor(() => {
expect(onClick).not.toHaveBeenCalled()
Expand Down
20 changes: 10 additions & 10 deletions packages/ui-checkbox/src/Checkbox/__tests__/Checkbox.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe('<Checkbox />', () => {

expect(svgElement).not.toBeInTheDocument()

userEvent.click(checkboxElement!)
await userEvent.click(checkboxElement!)
await waitFor(() => {
const svgElementAfterClick = container.querySelector('svg')
expect(svgElementAfterClick).toBeInTheDocument()
Expand Down Expand Up @@ -120,7 +120,7 @@ describe('<Checkbox />', () => {
renderCheckbox({ onClick, onChange })
const checkboxElement = screen.getByRole('checkbox')

userEvent.click(checkboxElement)
await userEvent.click(checkboxElement)

await waitFor(() => {
expect(onClick).toHaveBeenCalled()
Expand Down Expand Up @@ -172,7 +172,7 @@ describe('<Checkbox />', () => {
renderCheckbox({ onChange })
const checkboxElement = screen.getByRole('checkbox')

userEvent.type(checkboxElement, '{enter}')
await userEvent.type(checkboxElement, '{enter}')

await waitFor(() => {
expect(onChange).toHaveBeenCalled()
Expand All @@ -183,8 +183,8 @@ describe('<Checkbox />', () => {
const onBlur = vi.fn()
renderCheckbox({ onBlur })

userEvent.tab()
userEvent.tab()
await userEvent.tab()
await userEvent.tab()

await waitFor(() => {
expect(onBlur).toHaveBeenCalled()
Expand All @@ -195,7 +195,7 @@ describe('<Checkbox />', () => {
const onFocus = vi.fn()
renderCheckbox({ onFocus })

userEvent.tab()
await userEvent.tab()

await waitFor(() => {
expect(onFocus).toHaveBeenCalled()
Expand All @@ -219,7 +219,7 @@ describe('<Checkbox />', () => {
renderCheckbox({ onMouseOver })
const checkboxElement = screen.getByRole('checkbox')

userEvent.hover(checkboxElement)
await userEvent.hover(checkboxElement)

await waitFor(() => {
expect(onMouseOver).toHaveBeenCalled()
Expand All @@ -231,8 +231,8 @@ describe('<Checkbox />', () => {
renderCheckbox({ onMouseOut })
const checkboxElement = screen.getByRole('checkbox')

userEvent.hover(checkboxElement)
userEvent.unhover(checkboxElement)
await userEvent.hover(checkboxElement)
await userEvent.unhover(checkboxElement)

await waitFor(() => {
expect(onMouseOut).toHaveBeenCalled()
Expand All @@ -246,7 +246,7 @@ describe('<Checkbox />', () => {

expect(input).toHaveAttribute('data-checked', 'false')

userEvent.click(input)
await userEvent.click(input)
await waitFor(() => {
expect(input).toHaveAttribute('data-checked', 'true')
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ describe('<CheckboxGroup />', () => {
expect(checkboxes[0]).not.toBeChecked()
expect(checkboxes[1]).not.toBeChecked()

userEvent.click(checkboxes[0])
await userEvent.click(checkboxes[0])

await waitFor(() => {
expect(onChange).not.toHaveBeenCalled()
expect(onChange).toHaveBeenCalledWith(['tester', 'test-value-1'])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A controlled CheckboxGroup is supposed to fire onChange on every click (that's how it reports the user's intent to the parent) — it just never changes its own checked state.

expect(checkboxes[0]).not.toBeChecked()
expect(checkboxes[1]).not.toBeChecked()
})
Expand All @@ -155,8 +155,8 @@ describe('<CheckboxGroup />', () => {
expect(checkboxes[0]).not.toBeChecked()
expect(checkboxes[1]).not.toBeChecked()

userEvent.click(checkboxes[0])
userEvent.click(checkboxes[1])
await userEvent.click(checkboxes[0])
await userEvent.click(checkboxes[1])

await waitFor(() => {
expect(checkboxes[0]).toBeChecked()
Expand All @@ -183,7 +183,7 @@ describe('<CheckboxGroup />', () => {
expect(checkboxes[0]).toBeChecked()
expect(checkboxes[1]).toBeChecked()

userEvent.click(checkboxes[0])
await userEvent.click(checkboxes[0])

await waitFor(() => {
expect(checkboxes[0]).not.toBeChecked()
Expand All @@ -201,7 +201,7 @@ describe('<CheckboxGroup />', () => {
expect(checkboxes[0]).not.toBeChecked()
expect(checkboxes[1]).toBeChecked()

userEvent.click(checkboxes[0])
await userEvent.click(checkboxes[0])

await waitFor(() => {
expect(checkboxes[0]).toBeChecked()
Expand Down
10 changes: 5 additions & 5 deletions packages/ui-dialog/src/Dialog/__tests__/Dialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ describe('<Dialog />', () => {
const onDismiss = vi.fn()
renderDialog({ onDismiss, shouldCloseOnDocumentClick: true })

await waitFor(() => {
userEvent.click(document.body)
await waitFor(async () => {
await userEvent.click(document.body)
expect(onDismiss).toHaveBeenCalled()
})
Comment on lines +179 to 182
})
Expand All @@ -199,7 +199,7 @@ describe('<Dialog />', () => {
)
const nonTabbableContent = getByTestId('non-tabbable')

userEvent.tab()
await userEvent.tab()
await waitFor(() => {
expect(document.activeElement).toBe(nonTabbableContent)
})
Expand Down Expand Up @@ -350,8 +350,8 @@ describe('<Dialog />', () => {
expect(document.activeElement).toBe(inputTwo)
})

await waitFor(() => {
userEvent.tab()
await waitFor(async () => {
await userEvent.tab()
expect(onBlur).not.toHaveBeenCalled()
expect(document.activeElement).toBe(inputOne)
})
Comment on lines +353 to 357
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ describe('<Editable />', () => {
)
const childContainer = screen.getByTestId('child-container')

userEvent.click(childContainer)
await userEvent.click(childContainer)

await waitFor(() => expect(onChangeModeSpy).toHaveBeenCalledWith('edit'))
})
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-link/src/Link/__tests__/Link.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe('<Link />', () => {
)
const link = container.querySelector('span[class*="-link"]')!

userEvent.hover(link)
await userEvent.hover(link)

await waitFor(() => {
expect(onMouseEnter).toHaveBeenCalledTimes(1)
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-modal/src/Modal/__tests__/Modal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ describe.skip('<Modal />', () => {

expect(modalBody).toBeInTheDocument()

await userEvent.click(document.body)
await waitFor(() => {
userEvent.click(document.body)
expect(onDismiss).toHaveBeenCalled()
})
})
Expand Down Expand Up @@ -331,7 +331,7 @@ describe.skip('<Modal />', () => {

expect(dialog).toBeInTheDocument()

userEvent.click(getByTestId('outer-element'))
await userEvent.click(getByTestId('outer-element'))

await waitFor(() => {
expect(onClickOuter).toHaveBeenCalled()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe('<NumberInput />', () => {
render(<NumberInput renderLabel="Label" onChange={onChange} />)
const input = screen.getByRole('spinbutton')

userEvent.type(input, '5')
await userEvent.type(input, '5')

await waitFor(() => {
const event = onChange.mock.calls[0][0]
Expand All @@ -107,7 +107,7 @@ describe('<NumberInput />', () => {
render(<NumberInput renderLabel="Label" onKeyDown={onKeyDown} />)
const input = screen.getByRole('spinbutton')

userEvent.type(input, '5')
await userEvent.type(input, '5')

await waitFor(() => {
expect(onKeyDown).toHaveBeenCalledTimes(1)
Expand All @@ -118,8 +118,8 @@ describe('<NumberInput />', () => {
const onBlur = vi.fn()
render(<NumberInput renderLabel="Label" onBlur={onBlur} />)

userEvent.tab()
userEvent.tab()
await userEvent.tab()
await userEvent.tab()

await waitFor(() => {
expect(onBlur).toHaveBeenCalledTimes(1)
Expand Down Expand Up @@ -167,7 +167,7 @@ describe('<NumberInput />', () => {
'button[class$="-numberInput_arrow"]'
)

userEvent.click(buttons[0])
await userEvent.click(buttons[0])

await waitFor(() => {
expect(onIncrement).toHaveBeenCalledTimes(1)
Expand All @@ -187,7 +187,7 @@ describe('<NumberInput />', () => {
'button[class$="-numberInput_arrow"]'
)

userEvent.click(buttons[0])
await userEvent.click(buttons[0])

await waitFor(() => {
expect(onIncrement).toHaveBeenCalledTimes(0)
Expand All @@ -203,7 +203,7 @@ describe('<NumberInput />', () => {
'button[class$="-numberInput_arrow"]'
)

userEvent.click(buttons[0])
await userEvent.click(buttons[0])

await waitFor(() => {
expect(onIncrement).toHaveBeenCalledTimes(0)
Expand All @@ -220,7 +220,7 @@ describe('<NumberInput />', () => {
'button[class$="-numberInput_arrow"]'
)

userEvent.click(buttons[1])
await userEvent.click(buttons[1])

await waitFor(() => {
expect(onDecrement).toHaveBeenCalledTimes(1)
Expand All @@ -240,7 +240,7 @@ describe('<NumberInput />', () => {
'button[class$="-numberInput_arrow"]'
)

userEvent.click(buttons[1])
await userEvent.click(buttons[1])

await waitFor(() => {
expect(onDecrement).toHaveBeenCalledTimes(0)
Expand All @@ -256,7 +256,7 @@ describe('<NumberInput />', () => {
'button[class$="-numberInput_arrow"]'
)

userEvent.click(buttons[1])
await userEvent.click(buttons[1])

await waitFor(() => {
expect(onDecrement).toHaveBeenCalledTimes(0)
Expand Down Expand Up @@ -294,12 +294,12 @@ describe('<NumberInput />', () => {
'button[class$="-numberInput_arrow"]'
)

userEvent.click(buttons[0])
await userEvent.click(buttons[0])
await waitFor(() => {
expect(onIncrement).toHaveBeenCalledTimes(1)
})

userEvent.click(buttons[1])
await userEvent.click(buttons[1])
await waitFor(() => {
expect(onDecrement).toHaveBeenCalledTimes(1)
})
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-options/src/Options/__tests__/Item.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ describe('<Item />', () => {
'[class$="-optionItem__container"]'
)

userEvent.click(optionItem!)
await userEvent.click(optionItem!)
await waitFor(() => {
expect(onClick).not.toHaveBeenCalled()
})

userEvent.click(optionItemContainer!)
await userEvent.click(optionItemContainer!)
await waitFor(() => {
expect(onClick).toHaveBeenCalledTimes(1)
})
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-pages/src/Pages/__tests__/Pages.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ describe('<Pages />', () => {

const button = container.querySelector('button')!

userEvent.click(button)
await userEvent.click(button)

await waitFor(() => {
expect(onPageIndexChange).toHaveBeenCalledTimes(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ import { vi } from 'vitest'

import '@testing-library/jest-dom'
import { runAxeCheck } from '@instructure/ui-axe-check'
import { RadioInput, type RadioInputHandle } from '@instructure/ui-radio-input/latest'
import {
RadioInput,
type RadioInputHandle
} from '@instructure/ui-radio-input/latest'

describe('<RadioInput />', () => {
let consoleWarningMock: ReturnType<typeof vi.spyOn>
Expand Down Expand Up @@ -91,7 +94,7 @@ describe('<RadioInput />', () => {

const input = container.querySelector('input')

userEvent.click(input!)
await userEvent.click(input!)

await waitFor(() => {
expect(onClick).toHaveBeenCalled()
Expand Down Expand Up @@ -159,7 +162,7 @@ describe('<RadioInput />', () => {

const input = container.querySelector('input')

userEvent.click(input!)
await userEvent.click(input!)

await waitFor(() => {
expect(onChange).toHaveBeenCalled()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('<RadioInputGroup />', () => {
)
const input = container.querySelector('input')

userEvent.click(input!)
await userEvent.click(input!)

await waitFor(() => {
expect(onChange).toHaveBeenCalled()
Expand Down Expand Up @@ -153,7 +153,7 @@ describe('<RadioInputGroup />', () => {

expect(orange).toHaveAttribute('checked')

userEvent.click(banana!)
await userEvent.click(banana!)

await waitFor(() => {
expect(orange).toHaveAttribute('checked')
Expand Down
Loading
Loading