Skip to content

Commit b29c8ae

Browse files
committed
test: polish facet selector tests
1 parent 5b6c232 commit b29c8ae

2 files changed

Lines changed: 4 additions & 37 deletions

File tree

test/nuxt/components/compare/FacetSelector.spec.ts

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import type { ComparisonFacet } from '#shared/types/comparison'
2+
import { CATEGORY_ORDER, FACET_INFO, FACETS_BY_CATEGORY } from '#shared/types/comparison'
3+
import FacetSelector from '~/components/compare/FacetSelector.vue'
14
import { beforeEach, describe, expect, it, vi } from 'vitest'
25
import { ref } from 'vue'
36
import { mountSuspended } from '@nuxt/test-utils/runtime'
4-
import FacetSelector from '~/components/compare/FacetSelector.vue'
5-
import type { ComparisonFacet } from '../../../../shared/types/comparison'
6-
import { CATEGORY_ORDER, FACET_INFO, FACETS_BY_CATEGORY } from '../../../../shared/types/comparison'
77

88
// Mock useFacetSelection
99
const mockSelectedFacets = ref<string[]>(['downloads', 'types'])
@@ -219,39 +219,6 @@ describe('FacetSelector', () => {
219219
})
220220
})
221221

222-
describe('accessibility', () => {
223-
it('has role=group on main container', async () => {
224-
const component = await mountSuspended(FacetSelector)
225-
226-
expect(component.find('[role="group"]').exists()).toBe(true)
227-
})
228-
229-
it('has aria-label on facet group', async () => {
230-
const component = await mountSuspended(FacetSelector)
231-
232-
const groups = component.findAll('[role="group"]')
233-
expect(groups.length).toBeGreaterThan(0)
234-
})
235-
236-
it('facet buttons have aria-label', async () => {
237-
const component = await mountSuspended(FacetSelector)
238-
239-
const facetButtons = component.findAll('button[aria-pressed]')
240-
for (const button of facetButtons) {
241-
expect(button.attributes('aria-label')).toBeTruthy()
242-
}
243-
})
244-
245-
it('category buttons have aria-label', async () => {
246-
const component = await mountSuspended(FacetSelector)
247-
248-
const allButtons = component.findAll('button').filter(b => b.text() === 'all')
249-
for (const button of allButtons) {
250-
expect(button.attributes('aria-label')).toBeTruthy()
251-
}
252-
})
253-
})
254-
255222
describe('styling', () => {
256223
it('applies selected styling to selected facets', async () => {
257224
mockSelectedFacets.value = ['downloads']

test/nuxt/composables/use-facet-selection.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { beforeEach, describe, expect, it, vi } from 'vitest'
22
import { ref } from 'vue'
3-
import { DEFAULT_FACETS, FACETS_BY_CATEGORY } from '../../../shared/types/comparison'
3+
import { DEFAULT_FACETS, FACETS_BY_CATEGORY } from '#shared/types/comparison'
44

55
// Mock useRouteQuery
66
const mockRouteQuery = ref('')

0 commit comments

Comments
 (0)