- The switches and the seek bar of the player bar take a tap on 44 px (the switch is now one component). - The colour of the browser bar follows the theme instead of staying dark blue. - Paragraphs stop at 56 characters and no longer end on a lone word. Closes #130
23 lines
958 B
TypeScript
23 lines
958 B
TypeScript
import { render, screen } from '@testing-library/react'
|
|
import userEvent from '@testing-library/user-event'
|
|
import { expect, test, vi } from 'vitest'
|
|
import { Switch } from './switch'
|
|
|
|
test('it is a switch that says whether it is on and reports a click', async () => {
|
|
const onClick = vi.fn()
|
|
render(<Switch checked={false} aria-label="Wi-Fi" onClick={onClick} />)
|
|
const sw = screen.getByRole('switch', { name: 'Wi-Fi' })
|
|
expect(sw).toHaveAttribute('aria-checked', 'false')
|
|
await userEvent.click(sw)
|
|
expect(onClick).toHaveBeenCalledTimes(1)
|
|
})
|
|
|
|
test('the area that takes a tap is 44 pixels high, and a disabled switch ignores taps', async () => {
|
|
const onClick = vi.fn()
|
|
render(<Switch checked disabled aria-label="Wi-Fi" onClick={onClick} />)
|
|
const sw = screen.getByRole('switch')
|
|
expect(sw).toHaveClass('h-11')
|
|
expect(sw).toHaveAttribute('aria-checked', 'true')
|
|
await userEvent.click(sw)
|
|
expect(onClick).not.toHaveBeenCalled()
|
|
})
|