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

28 lines
824 B
TypeScript
Raw Normal View History

import { screen } from '@testing-library/vue'
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))
2022-07-10 09:38:19 +00:00
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(screen.queryAllByTestId('album-track-item')).toHaveLength(3)
})
}
}