import { beVisible, haveClasses, haveFocus, html, notBeVisible, notHaveClasses, test } from '../../../utils' test('can use tabs to toggle panels', [html`
First Panel
Second Panel
`], ({ get }) => { get('[panel-1]').should(beVisible()) get('[panel-2]').should(notBeVisible()) get('[button-2]').click() get('[panel-1]').should(notBeVisible()) get('[panel-2]').should(beVisible()) }, ) test('can use arrow keys to cycle through tabs', [html`
First Panel
Second Panel
`], ({ get }) => { get('[panel-1]').should(beVisible()) get('[panel-2]').should(notBeVisible()) get('[button-2]').click() get('[button-2]').should(haveFocus()) get('[panel-1]').should(notBeVisible()) get('[panel-2]').should(beVisible()) get('[button-2]').type('{rightArrow}') get('[button-1]').should(haveFocus()) get('[panel-1]').should(beVisible()) get('[panel-2]').should(notBeVisible()) get('[button-1]').type('{rightArrow}') get('[button-2]').should(haveFocus()) get('[panel-1]').should(notBeVisible()) get('[panel-2]').should(beVisible()) }, ) test('cant tab through tabs, can only use arrows', [html`
First Panel
Second Panel
`], ({ get }) => { get('[button-1]').click() get('[button-1]').should(haveFocus()) get('[button-1]').tab() get('[button-2]').should(haveFocus()) get('[button-2]').tab() get('[panel-1]').should(haveFocus()) get('[panel-1]').tab() get('[button-4]').should(haveFocus()) }, ) test('can detect the selected tab & panel', [html`
First Panel
Second Panel
`], ({ get }) => { get('[panel-1]').should(beVisible()) get('[panel-2]').should(notBeVisible()) get('[button-1]').should(haveClasses(['active'])) get('[panel-1]').should(haveClasses(['active'])) get('[button-2]').should(notHaveClasses(['active'])) get('[panel-2]').should(notHaveClasses(['active'])) get('[button-2]').click() get('[button-1]').should(notHaveClasses(['active'])) get('[panel-1]').should(notHaveClasses(['active'])) get('[button-2]').should(haveClasses(['active'])) get('[panel-2]').should(haveClasses(['active'])) get('[panel-1]').should(notBeVisible()) get('[panel-2]').should(beVisible()) }, ) test('can disable a tab', [html`
First Panel
Second Panel
Third Panel
`], ({ get }) => { get('[button-2]').should(haveClasses(['disabled'])) get('[button-1]').click() get('[button-1]').should(haveFocus()) get('[panel-1]').should(beVisible()) get('[panel-2]').should(notBeVisible()) get('[button-1]').type('{rightArrow}') get('[panel-1]').should(notBeVisible()) get('[panel-3]').should(beVisible()) get('[button-3]').type('{rightArrow}') get('[panel-3]').should(notBeVisible()) get('[panel-1]').should(beVisible()) }, ) test('can traverse tabs manually', [html`
First Panel
Second Panel
`], ({ get }) => { get('[button-1]').click() get('[button-1]').should(haveFocus()) get('[panel-1]').should(beVisible()) get('[panel-2]').should(notBeVisible()) get('[button-1]').type('{rightArrow}') get('[button-2]').should(haveFocus()) get('[panel-1]').should(beVisible()) get('[panel-2]').should(notBeVisible()) get('[button-2]').click() get('[panel-1]').should(notBeVisible()) get('[panel-2]').should(beVisible()) }, ) test('can set a default index', [html`
First Panel
Second Panel
`], ({ get }) => { get('[panel-1]').should(notBeVisible()) get('[panel-2]').should(beVisible()) }, ) test('can programmatically control the selected tab', [html`
First Panel
Second Panel
`], ({ get }) => { get('[panel-1]').should(notBeVisible()) get('[panel-2]').should(beVisible()) get('[button-toggle]').click() get('[panel-2]').should(notBeVisible()) get('[panel-1]').should(beVisible()) get('[button-toggle]').click() get('[panel-1]').should(notBeVisible()) get('[panel-2]').should(beVisible()) }, )