koel/resources/assets/js/components/layout/main-wrapper/extra-drawer/ExtraDrawerTabHeader.spec.ts

33 lines
1.1 KiB
TypeScript
Raw Normal View History

2022-10-13 15:18:47 +00:00
import { expect, it } from 'vitest'
import UnitTestCase from '@/__tests__/UnitTestCase'
import { commonStore } from '@/stores'
import { screen } from '@testing-library/vue'
import ExtraDrawerTabHeader from './ExtraDrawerTabHeader.vue'
2022-10-13 15:18:47 +00:00
new class extends UnitTestCase {
protected test () {
it('renders tab headers', () => {
2024-01-04 11:35:36 +00:00
commonStore.state.uses_you_tube = false
this.render(ExtraDrawerTabHeader)
2022-10-13 15:18:47 +00:00
;['Lyrics', 'Artist information', 'Album information'].forEach(name => screen.getByRole('button', { name }))
expect(screen.queryByRole('button', { name: 'Related YouTube videos' })).toBeNull()
2022-10-13 15:18:47 +00:00
})
it('has a YouTube tab header if using YouTube', () => {
2024-01-04 11:35:36 +00:00
commonStore.state.uses_you_tube = true
this.render(ExtraDrawerTabHeader)
2022-10-13 15:18:47 +00:00
screen.getByRole('button', { name: 'Related YouTube videos' })
2022-10-13 15:18:47 +00:00
})
it('emits the selected tab value', async () => {
const { emitted } = this.render(ExtraDrawerTabHeader)
2022-10-13 15:18:47 +00:00
await this.user.click(screen.getByRole('button', { name: 'Lyrics' }))
2022-10-13 15:18:47 +00:00
expect(emitted()['update:modelValue']).toEqual([['Lyrics']])
})
}
}