2022-05-09 09:59:31 +00:00
|
|
|
import { expect, it } from 'vitest'
|
|
|
|
import { fireEvent } from '@testing-library/vue'
|
2022-05-06 15:52:37 +00:00
|
|
|
import factory from '@/__tests__/factory'
|
|
|
|
import { commonStore } from '@/stores'
|
2022-05-13 17:58:38 +00:00
|
|
|
import UnitTestCase from '@/__tests__/UnitTestCase'
|
2022-05-06 10:28:02 +00:00
|
|
|
import ExtraPanel from './ExtraPanel.vue'
|
|
|
|
|
2022-05-13 17:58:38 +00:00
|
|
|
new class extends UnitTestCase {
|
2022-05-09 09:59:31 +00:00
|
|
|
private renderComponent () {
|
|
|
|
return this.render(ExtraPanel, {
|
|
|
|
props: {
|
|
|
|
song: factory<Song>('song')
|
|
|
|
},
|
|
|
|
global: {
|
|
|
|
stubs: {
|
|
|
|
LyricsPane: this.stub(),
|
|
|
|
AlbumInfo: this.stub(),
|
|
|
|
ArtistInfo: this.stub(),
|
|
|
|
YouTubeVideoList: this.stub()
|
|
|
|
}
|
2022-05-06 10:28:02 +00:00
|
|
|
}
|
2022-05-09 09:59:31 +00:00
|
|
|
})
|
|
|
|
}
|
2022-05-06 10:28:02 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
protected test () {
|
|
|
|
it('has a YouTube tab if using YouTube ', () => {
|
2022-06-10 10:47:46 +00:00
|
|
|
commonStore.state.use_you_tube = true
|
2022-05-09 09:59:31 +00:00
|
|
|
const { getByTestId } = this.renderComponent()
|
2022-05-06 10:28:02 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
getByTestId('extra-tab-youtube')
|
|
|
|
})
|
2022-05-06 10:28:02 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
it('does not have a YouTube tab if not using YouTube', async () => {
|
2022-06-10 10:47:46 +00:00
|
|
|
commonStore.state.use_you_tube = false
|
2022-05-09 09:59:31 +00:00
|
|
|
const { queryByTestId } = this.renderComponent()
|
2022-05-06 10:28:02 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
expect(await queryByTestId('extra-tab-youtube')).toBeNull()
|
|
|
|
})
|
2022-05-06 10:28:02 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
it.each([['extra-tab-lyrics'], ['extra-tab-album'], ['extra-tab-artist']])('switches to "%s" tab', async (id) => {
|
|
|
|
const { getByTestId, container } = this.renderComponent()
|
2022-05-06 10:28:02 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
await fireEvent.click(getByTestId(id))
|
2022-05-06 10:28:02 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
expect(container.querySelector('[aria-selected=true]')).toBe(getByTestId(id))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|