2022-05-09 09:59:31 +00:00
|
|
|
import { expect, it } from 'vitest'
|
|
|
|
import { fireEvent } from '@testing-library/vue'
|
2022-05-03 16:51:59 +00:00
|
|
|
import factory from '@/__tests__/factory'
|
2022-05-09 09:59:31 +00:00
|
|
|
import ComponentTestCase from '@/__tests__/ComponentTestCase'
|
2022-05-04 21:01:35 +00:00
|
|
|
import AlbumInfo from './AlbumInfo.vue'
|
2022-05-03 16:51:59 +00:00
|
|
|
import AlbumThumbnail from '@/components/ui/AlbumArtistThumbnail.vue'
|
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
new class extends ComponentTestCase {
|
|
|
|
protected test () {
|
|
|
|
it.each([['sidebar'], ['full']])('renders in %s mode', async (mode: string) => {
|
|
|
|
const { getByTestId } = this.render(AlbumInfo, {
|
|
|
|
props: {
|
|
|
|
mode,
|
|
|
|
album: factory<Album>('album')
|
|
|
|
},
|
|
|
|
global: {
|
|
|
|
stubs: {
|
|
|
|
AlbumThumbnail
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2022-05-03 16:51:59 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
getByTestId('album-artist-thumbnail')
|
2022-05-03 16:51:59 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
const element = getByTestId<HTMLElement>('album-info')
|
|
|
|
expect(element.classList.contains(mode)).toBe(true)
|
|
|
|
})
|
2022-05-03 16:51:59 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
it('triggers showing full wiki', async () => {
|
|
|
|
const album = factory<Album>('album')
|
2022-05-03 16:51:59 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
const { getByText } = this.render(AlbumInfo, {
|
|
|
|
props: {
|
|
|
|
album
|
|
|
|
}
|
|
|
|
})
|
2022-05-04 21:01:35 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
await fireEvent.click(getByText('Full Wiki'))
|
|
|
|
getByText(album.info!.wiki!.full)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|