import { haveAttribute, haveFocus, html, haveClasses, notHaveClasses, test, haveText, notExist, beHidden, } from '../../../utils' test('it works using x-model', [html`

Privacy setting

`], ({ get }) => { get('input').should(haveAttribute('value', '')) get('[option="access-2"]').click() get('input').should(haveAttribute('value', 'access-2')) get('[option="access-4"]').click() get('input').should(haveAttribute('value', 'access-4')) }, ) test('it works without x-model/with default-value', [html`

Privacy setting

`], ({ get }) => { get('[option="access-4"]').should(haveAttribute('aria-checked', 'true')) get('[option="access-2"]').click() get('[option="access-2"]').should(haveAttribute('aria-checked', 'true')) }, ) test('cannot select any option when the group is disabled', [html`
`], ({ get }) => { get('input').should(haveAttribute('value', '')) get('[option="access-1"]').click() get('input').should(haveAttribute('value', '')) }, ) test('cannot select a disabled option', [html`
`], ({ get }) => { get('input').should(haveAttribute('value', '')) get('[option="access-3"]').click() get('input').should(haveAttribute('value', '')) }, ) test('keyboard navigation works', [html`
`], ({ get }) => { get('input').should(haveAttribute('value', '')) get('[option="access-1"]').focus().type('{downarrow}') get('[option="access-2"]').should(haveFocus()).type('{downarrow}') get('[option="access-4"]').should(haveFocus()).type('{downarrow}') get('[option="access-1"]').should(haveFocus()) }, ) test('has accessibility attributes', [html`

Privacy setting

Some description

`], ({ get }) => { get('[group]').should(haveAttribute('role', 'radiogroup')) .should(haveAttribute('aria-labelledby', 'alpine-radio-label-1')) .should(haveAttribute('aria-describedby', 'alpine-radio-description-1')) get('h2').should(haveAttribute('id', 'alpine-radio-label-1')) get('p').should(haveAttribute('id', 'alpine-radio-description-1')) get('[option="access-1"]') .should(haveAttribute('tabindex', 0)) for (i in 4) { get(`[option="access-${i}"]`) .should(haveAttribute('role', 'radio')) .should(haveAttribute('aria-disabled', 'false')) .should(haveAttribute('aria-labelledby', `alpine-radio-label-${i + 1}`)) .should(haveAttribute('aria-describedby', `alpine-radio-description-${i + 1}`)) get(`[label="access-${i}"]`) .should(haveAttribute('id', `alpine-radio-label-${i + 1}`)) get(`[description="access-${i}"]`) .should(haveAttribute('id', `alpine-radio-description-${i + 1}`)) } get('[option="access-1"]') .click() .should(haveAttribute('aria-checked', 'true')) }, ) test('$radioOption.isActive, $radioOption.isChecked, $radioOption.isDisabled work', [html`
`], ({ get }) => { get('[option="access-1"]') .should(notHaveClasses(['active', 'checked', 'disabled'])) .focus() .should(haveClasses(['active'])) .should(notHaveClasses(['checked'])) .type(' ') .should(haveClasses(['active', 'checked'])) .type('{downarrow}') get('[option="access-2"]') .should(haveClasses(['active', 'checked'])) get('[option="access-3"]') .should(haveClasses(['disabled'])) }, ) test('can bind objects to the value', [html`
`], ({ get }) => { get('[option="access-2"]').click() get('article') .should(haveText(JSON.stringify({ id: 'access-2', name: 'Private to Project Members', description: 'Only members of this project would be able to access', disabled: false, }))) }, ) test('name prop', [html`
`], ({ get }) => { get('input').should(notExist()) get('[option="access-2"]').click() get('input').should(beHidden()) .should(haveAttribute('name', 'access')) .should(haveAttribute('value', 'access-2')) .should(haveAttribute('type', 'hidden')) get('[option="access-4"]').click() get('input').should(beHidden()) .should(haveAttribute('name', 'access')) .should(haveAttribute('value', 'access-4')) .should(haveAttribute('type', 'hidden')) }, )