diff --git a/client/src/features/book/components/FilterFormatPicker.spec.ts b/client/src/features/book/components/FilterFormatPicker.spec.ts new file mode 100644 index 000000000..b3995158b --- /dev/null +++ b/client/src/features/book/components/FilterFormatPicker.spec.ts @@ -0,0 +1,17 @@ +import { mount } from '@vue/test-utils' +import { describe, expect, it } from 'vitest' +import { BOOK_FORMATS, READ_ALONG_FORMAT_PRIORITY } from '@bookorbit/types' +import FilterFormatPicker from './FilterFormatPicker.vue' + +describe('FilterFormatPicker', () => { + it('offers read-along beside the physical book formats', async () => { + const wrapper = mount(FilterFormatPicker, { props: { modelValue: [] } }) + const buttons = wrapper.findAll('button') + const readAlong = buttons.find((button) => button.attributes('aria-label') === 'Read-along EPUB') + + expect(buttons).toHaveLength(BOOK_FORMATS.length + 1) + expect(readAlong).toBeDefined() + await readAlong!.trigger('click') + expect(wrapper.emitted('update:modelValue')).toEqual([[[READ_ALONG_FORMAT_PRIORITY]]]) + }) +}) diff --git a/client/src/features/book/components/FilterFormatPicker.vue b/client/src/features/book/components/FilterFormatPicker.vue index 686012e97..3699888d4 100644 --- a/client/src/features/book/components/FilterFormatPicker.vue +++ b/client/src/features/book/components/FilterFormatPicker.vue @@ -1,5 +1,7 @@