koel/resources/assets/js/components/album/AlbumInfo.spec.ts

41 lines
1,017 B
TypeScript
Raw Normal View History

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