Skip to content

Commit 77c6267

Browse files
committed
test: add button tests
1 parent a2872d6 commit 77c6267

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

test/nuxt/a11y.spec.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ import {
6363
AppHeader,
6464
BaseCard,
6565
BuildEnvironment,
66+
ButtonBase,
67+
ButtonLink,
6668
CallToAction,
6769
CodeDirectoryListing,
6870
CodeFileTree,
@@ -281,6 +283,25 @@ describe('component accessibility audits', () => {
281283
})
282284
})
283285

286+
describe('ButtonBase', () => {
287+
it('should have no accessibility violations', async () => {
288+
const component = await mountSuspended(ButtonBase, {
289+
slots: { default: 'Button content' },
290+
})
291+
const results = await runAxe(component)
292+
expect(results.violations).toEqual([])
293+
})
294+
295+
it('should have no accessibility violations for disabled state', async () => {
296+
const component = await mountSuspended(ButtonBase, {
297+
props: { disabled: true },
298+
slots: { default: 'Button content' },
299+
})
300+
const results = await runAxe(component)
301+
expect(results.violations).toEqual([])
302+
})
303+
})
304+
284305
describe('TagLink', () => {
285306
it('should have no accessibility violations', async () => {
286307
const component = await mountSuspended(TagLink, {
@@ -310,6 +331,35 @@ describe('component accessibility audits', () => {
310331
})
311332
})
312333

334+
describe('ButtonLink', () => {
335+
it('should have no accessibility violations', async () => {
336+
const component = await mountSuspended(ButtonLink, {
337+
props: { href: 'http://example.com' },
338+
slots: { default: 'Button link content' },
339+
})
340+
const results = await runAxe(component)
341+
expect(results.violations).toEqual([])
342+
})
343+
344+
it("should have no accessibility violations when it's the current link", async () => {
345+
const component = await mountSuspended(ButtonLink, {
346+
props: { href: 'http://example.com', current: true },
347+
slots: { default: 'Button link content' },
348+
})
349+
const results = await runAxe(component)
350+
expect(results.violations).toEqual([])
351+
})
352+
353+
it('should have no accessibility violations when disabled (plain text)', async () => {
354+
const component = await mountSuspended(ButtonLink, {
355+
props: { href: 'http://example.com', disabled: true },
356+
slots: { default: 'Button link content' },
357+
})
358+
const results = await runAxe(component)
359+
expect(results.violations).toEqual([])
360+
})
361+
})
362+
313363
describe('TagRadioButton', () => {
314364
it('should have no accessibility violations', async () => {
315365
const component = await mountSuspended(TagRadioButton, {

0 commit comments

Comments
 (0)