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

27 lines
804 B
TypeScript
Raw Normal View History

2022-05-03 16:51:59 +00:00
import factory from '@/__tests__/factory'
import { expect, it } from 'vitest'
2022-05-13 17:58:38 +00:00
import UnitTestCase from '@/__tests__/UnitTestCase'
2022-05-03 16:51:59 +00:00
import AlbumTrackList from './AlbumTrackList.vue'
2022-07-10 09:38:19 +00:00
import { songStore } from '@/stores'
2022-05-03 16:51:59 +00:00
2022-05-13 17:58:38 +00:00
new class extends UnitTestCase {
protected test () {
2022-07-10 09:38:19 +00:00
it('displays the tracks', async () => {
const album = factory<Album>('album')
const fetchMock = this.mock(songStore, 'fetchForAlbum').mockResolvedValue(factory<Song[]>('song', 5))
const { queryAllByTestId } = this.render(AlbumTrackList, {
props: {
2022-07-10 09:38:19 +00:00
album,
tracks: factory<AlbumTrack[]>('album-track', 3)
}
})
2022-05-03 16:51:59 +00:00
2022-07-10 09:38:19 +00:00
await this.tick()
expect(fetchMock).toHaveBeenCalledWith(album)
expect(queryAllByTestId('album-track-item')).toHaveLength(3)
})
}
}