2
0
mirror of https://github.com/tenrok/vue-select.git synced 2026-05-17 02:29:37 +03:00
Files
vue-select/tests/unit/Accessibility.spec.js
Jeff Sagal 98c278b2bb build(vite): replace webpack with Vite, add Typescript (#1594)
BREAKING: mixins are no longer exported from the index (and will likely be converted to hooks)
2022-07-18 09:33:46 -07:00

53 lines
1.5 KiB
JavaScript

import { it, describe, expect } from 'vitest'
import { mountDefault } from '@tests/helpers.js'
describe('Search Slot Scope', () => {
/**
* @see https://www.w3.org/WAI/PF/aria/states_and_properties#aria-activedescendant
*/
describe('aria-activedescendant', () => {
it('adds the active descendant attribute only when the dropdown is open and there is a typeAheadPointer value', async () => {
const Select = mountDefault()
expect(
Select.vm.scope.search.attributes['aria-activedescendant']
).toEqual(undefined)
Select.vm.open = true
await Select.vm.$nextTick()
expect(
Select.vm.scope.search.attributes['aria-activedescendant']
).toEqual(undefined)
})
it("adds the active descendant attribute when there's a typeahead value and an open dropdown", async () => {
const Select = mountDefault({ modelValue: 'three' }, [
'one',
'two',
'three',
])
Select.vm.open = true
Select.vm.typeAheadPointer = 1
await Select.vm.$nextTick()
expect(
Select.vm.scope.search.attributes['aria-activedescendant']
).toEqual(`vs${Select.vm.uid}__option-2`)
})
})
})
describe('UID', () => {
it('works with strings', () => {
const Select = mountDefault({ uid: 'hello' })
expect(Select.find('#vshello__combobox').exists()).toBeTruthy()
})
it('works with numbers', () => {
const Select = mountDefault({ uid: 2 })
expect(Select.find('#vs2__combobox').exists()).toBeTruthy()
})
})