Re-introduce accessibility tests

This commit is contained in:
Owen Niblock 2024-02-29 11:11:22 +00:00
Родитель d4d48fdc02
Коммит 0f621b7813
1 изменённых файлов: 29 добавлений и 1 удалений

Просмотреть файл

@ -1,4 +1,4 @@
import {assert} from '@open-wc/testing'
import {assert, expect} from '@open-wc/testing'
import '../src/index.ts'
describe('tab-container', function () {
@ -68,9 +68,16 @@ describe('tab-container', function () {
})
afterEach(function () {
// Check to make sure we still have accessible markup after the test finishes running.
expect(document.body).to.be.accessible()
document.body.innerHTML = ''
})
it('has accessible markup', function () {
expect(document.body).to.be.accessible()
})
it('the second tab is still selected', function () {
assert.deepStrictEqual(tabs.map(isSelected), [false, true, false], 'Second tab is selected')
assert.deepStrictEqual(panels.map(isHidden), [true, false, true], 'Second panel is visible')
@ -100,9 +107,16 @@ describe('tab-container', function () {
})
afterEach(function () {
// Check to make sure we still have accessible markup after the test finishes running.
expect(document.body).to.be.accessible()
document.body.innerHTML = ''
})
it('has accessible markup', function () {
expect(document.body).to.be.accessible()
})
it('the second tab is still selected', function () {
assert.deepStrictEqual(tabs.map(isSelected), [false, true, false], 'Second tab is selected')
assert.deepStrictEqual(panels.map(isHidden), [true, false, true], 'Second panel is visible')
@ -138,9 +152,16 @@ describe('tab-container', function () {
})
afterEach(function () {
// Check to make sure we still have accessible markup after the test finishes running.
expect(document.body).to.be.accessible()
document.body.innerHTML = ''
})
it('has accessible markup', function () {
expect(document.body).to.be.accessible()
})
it('click works and `tab-container-changed` event is dispatched', function () {
tabs[1].click()
assert.deepStrictEqual(tabs.map(isSelected), [false, true, false], 'Second tab is selected')
@ -331,9 +352,16 @@ describe('tab-container', function () {
})
afterEach(function () {
// Check to make sure we still have accessible markup after the test finishes running.
expect(document.body).to.be.accessible()
document.body.innerHTML = ''
})
it('has accessible markup', function () {
expect(document.body).to.be.accessible()
})
it('only switches closest tab-containers on click', () => {
assert.deepStrictEqual(tabs.map(isSelected), [true, false, false])
assert.deepStrictEqual(nestedTabs.map(isSelected), [true, false])