2022-11-29 10:18:58 +00:00
|
|
|
import { screen } 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 { 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 {
|
2022-05-09 09:59:31 +00:00
|
|
|
protected test () {
|
2022-07-10 09:38:19 +00:00
|
|
|
it('displays the tracks', async () => {
|
|
|
|
const album = factory<Album>('album')
|
2022-09-12 15:33:41 +00:00
|
|
|
const fetchMock = this.mock(songStore, 'fetchForAlbum').mockResolvedValue(factory<Song>('song', 5))
|
2022-07-10 09:38:19 +00:00
|
|
|
|
2022-11-29 10:18:58 +00:00
|
|
|
this.render(AlbumTrackList, {
|
2022-05-09 09:59:31 +00:00
|
|
|
props: {
|
2022-07-10 09:38:19 +00:00
|
|
|
album,
|
2022-09-12 15:33:41 +00:00
|
|
|
tracks: factory<AlbumTrack>('album-track', 3)
|
2022-05-09 09:59:31 +00:00
|
|
|
}
|
|
|
|
})
|
2022-05-03 16:51:59 +00:00
|
|
|
|
2022-07-10 09:38:19 +00:00
|
|
|
await this.tick()
|
|
|
|
|
|
|
|
expect(fetchMock).toHaveBeenCalledWith(album)
|
2022-11-29 10:18:58 +00:00
|
|
|
expect(screen.queryAllByTestId('album-track-item')).toHaveLength(3)
|
2022-05-09 09:59:31 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|