import { beHidden, beVisible, haveAttribute, haveClasses, haveText, html, notBeVisible, notExist, test } from '../../../utils' test('has accessibility attributes', [html`
A description of the switch.
`], ({ get }) => { get('label').should(haveAttribute('id', 'alpine-switch-label-1')) get('[description]').should(haveAttribute('id', 'alpine-switch-description-1')) get('button').should(haveAttribute('type', 'button')) get('button').should(haveAttribute('aria-labelledby', 'alpine-switch-label-1')) get('button').should(haveAttribute('aria-describedby', 'alpine-switch-description-1')) get('button').should(haveAttribute('role', 'switch')) get('button').should(haveAttribute('tabindex', 0)) get('button').should(haveAttribute('aria-checked', 'false')) get('button').click() get('button').should(haveAttribute('aria-checked', 'true')) }, ) test('works with x-model', [html`
Notifications are enabled.
`], ({ get }) => { get('article').should(notBeVisible()) get('button').click() get('article').should(beVisible()) get('button').click() get('article').should(notBeVisible()) }, ) test('works with internal state/$switch.isChecked', [html`
`], ({ get }) => { get('button').should(haveClasses(['bar'])) get('button').click() get('button').should(haveClasses(['foo'])) get('button').click() get('button').should(haveClasses(['bar'])) }, ) test('pressing space toggles the switch', [html`
Notifications are enabled.
`], ({ get }) => { get('article').should(notBeVisible()) get('button').focus() get('button').type(' ') get('article').should(beVisible()) get('button').type(' ') get('article').should(notBeVisible()) }, ) test('default-checked', [html`
`], ({ get }) => { get('button').should(haveClasses(['checked'])) get('button').click() get('button').should(haveClasses(['not-checked'])) }, ) test('name and value props', [html`
`], ({ get }) => { get('input').should(notExist()) get('button').click() get('input').should(beHidden()) .should(haveAttribute('name', 'notifications')) .should(haveAttribute('value', 'yes')) .should(haveAttribute('type', 'hidden')) get('button').click() get('input').should(notExist()) }, ) test('value defaults to "on"', [html`
`], ({ get }) => { get('input').should(notExist()) get('button').click() get('input').should(beHidden()) .should(haveAttribute('name', 'notifications')) .should(haveAttribute('value', 'on')) .should(haveAttribute('type', 'hidden')) get('button').click() get('input').should(notExist()) }, )