From a75a71994af6415cce3343dcd7bf65527fc982e8 Mon Sep 17 00:00:00 2001 From: Christos Hrousis Date: Tue, 5 Oct 2021 23:53:28 +1100 Subject: [PATCH] test: component/spinner (#556) - covers accessibility - provides explainer for aria-busy and aria-live tags. --- src/components/spinner/spinner.test.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/components/spinner/spinner.test.ts diff --git a/src/components/spinner/spinner.test.ts b/src/components/spinner/spinner.test.ts new file mode 100644 index 00000000..25f88a94 --- /dev/null +++ b/src/components/spinner/spinner.test.ts @@ -0,0 +1,25 @@ +import { expect, fixture, html } from '@open-wc/testing'; + +import '../../../dist/shoelace.js'; +import type SlSpinner from './spinner'; + +describe('', () => { + let el: SlSpinner; + + describe('when provided no parameters', () => { + before(async () => { + el = await fixture(html` `); + }); + + it('should render a component that passes accessibility test.', async () => { + await expect(el).to.be.accessible(); + }); + + it('should defer updates to screen reader users via aria-live="polite".', async () => { + // https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions + const base = el.shadowRoot?.querySelector('[part="base"]') as SVGElement; + await expect(base).have.attribute('aria-busy', 'true'); + await expect(base).have.attribute('aria-live', 'polite'); + }); + }); +});