Skip to content

Commit 651cdf1

Browse files
committed
test: add a11y tests for selects
1 parent 357795d commit 651cdf1

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

test/nuxt/a11y.spec.ts

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ import {
176176
ReadmeTocDropdown,
177177
SearchProviderToggle,
178178
SearchSuggestionCard,
179+
SelectBase,
180+
SelectField,
179181
SettingsAccentColorPicker,
180182
SettingsBgThemePicker,
181183
SettingsToggle,
@@ -2232,6 +2234,93 @@ describe('component accessibility audits', () => {
22322234
})
22332235
})
22342236

2237+
describe('SelectBase', () => {
2238+
it('should have no accessibility violations with options and aria-label', async () => {
2239+
const component = await mountSuspended(SelectBase, {
2240+
attrs: { 'aria-label': 'Choose option' },
2241+
slots: {
2242+
default:
2243+
'<option value="option1">option 1</option><option value="option2">option 2</option>',
2244+
},
2245+
})
2246+
const results = await runAxe(component)
2247+
expect(results.violations).toEqual([])
2248+
})
2249+
2250+
it('should have no accessibility violations when disabled', async () => {
2251+
const component = await mountSuspended(SelectBase, {
2252+
props: { disabled: true },
2253+
attrs: { 'aria-label': 'Disabled select' },
2254+
slots: { default: '<option value="option1">option 1</option>' },
2255+
})
2256+
const results = await runAxe(component)
2257+
expect(results.violations).toEqual([])
2258+
})
2259+
2260+
it('should have no accessibility violations with size small', async () => {
2261+
const component = await mountSuspended(SelectBase, {
2262+
props: { size: 'sm' },
2263+
slots: { default: '<option value="option1">option 1</option>' },
2264+
})
2265+
const results = await runAxe(component)
2266+
expect(results.violations).toEqual([])
2267+
})
2268+
})
2269+
2270+
describe('SelectField', () => {
2271+
it('should have no accessibility violations with label and items', async () => {
2272+
const component = await mountSuspended(SelectField, {
2273+
props: {
2274+
id: 'a11y-select-1',
2275+
label: 'Choose one',
2276+
items: [
2277+
{ label: 'Option 1', value: 'option1' },
2278+
{ label: 'Option 2', value: 'option2' },
2279+
],
2280+
},
2281+
})
2282+
const results = await runAxe(component)
2283+
expect(results.violations).toEqual([])
2284+
})
2285+
2286+
it('should have no accessibility violations with hiddenLabel', async () => {
2287+
const component = await mountSuspended(SelectField, {
2288+
props: {
2289+
id: 'a11y-select-2',
2290+
label: 'Hidden',
2291+
hiddenLabel: true,
2292+
items: [{ label: 'Option 1', value: 'option1' }],
2293+
},
2294+
})
2295+
const results = await runAxe(component)
2296+
expect(results.violations).toEqual([])
2297+
})
2298+
2299+
it('should have no accessibility violations when disabled', async () => {
2300+
const component = await mountSuspended(SelectField, {
2301+
props: {
2302+
id: 'a11y-select-3',
2303+
items: [{ label: 'Option 1', value: 'option1' }],
2304+
disabled: true,
2305+
},
2306+
})
2307+
const results = await runAxe(component)
2308+
expect(results.violations).toEqual([])
2309+
})
2310+
2311+
it('should have no accessibility violations with size small', async () => {
2312+
const component = await mountSuspended(SelectField, {
2313+
props: {
2314+
id: 'a11y-select-4',
2315+
items: [{ label: 'Option 1', value: 'option1' }],
2316+
size: 'sm',
2317+
},
2318+
})
2319+
const results = await runAxe(component)
2320+
expect(results.violations).toEqual([])
2321+
})
2322+
})
2323+
22352324
describe('SearchSuggestionCard', () => {
22362325
it('should have no accessibility violations for user suggestion', async () => {
22372326
const component = await mountSuspended(SearchSuggestionCard, {

0 commit comments

Comments
 (0)