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 () => {
|
2024-06-01 18:02:27 +00:00
|
|
|
const album = factory('album')
|
|
|
|
const fetchMock = this.mock(songStore, 'fetchForAlbum').mockResolvedValue(factory('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,
|
2024-10-13 17:37:01 +00:00
|
|
|
tracks: factory('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
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|