sonda/web/src/components/ui/switch.test.tsx
tgiachi f0135cc548 fix(web): tap targets of 44 px, a browser bar that follows the theme, shorter lines
- 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
2026-11-13 12:56:26 +01:00

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