2022-10-13 15:18:47 +00:00
|
|
|
import { expect, it } from 'vitest'
|
|
|
|
import UnitTestCase from '@/__tests__/UnitTestCase'
|
|
|
|
import { commonStore } from '@/stores'
|
2022-11-29 10:18:58 +00:00
|
|
|
import { screen } from '@testing-library/vue'
|
2022-12-15 17:16:36 +00:00
|
|
|
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
|
2022-12-15 17:16:36 +00:00
|
|
|
this.render(ExtraDrawerTabHeader)
|
2022-10-13 15:18:47 +00:00
|
|
|
|
2022-11-29 10:18:58 +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
|
2022-12-15 17:16:36 +00:00
|
|
|
this.render(ExtraDrawerTabHeader)
|
2022-10-13 15:18:47 +00:00
|
|
|
|
2022-11-29 10:18:58 +00:00
|
|
|
screen.getByRole('button', { name: 'Related YouTube videos' })
|
2022-10-13 15:18:47 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('emits the selected tab value', async () => {
|
2022-12-15 17:16:36 +00:00
|
|
|
const { emitted } = this.render(ExtraDrawerTabHeader)
|
2022-10-13 15:18:47 +00:00
|
|
|
|
2022-11-29 10:18:58 +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']])
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|