mirror of
https://github.com/koel/koel
synced 2024-11-28 06:50:27 +00:00
fix(test): AlbumTrackList tests
This commit is contained in:
parent
7f81f3e6c7
commit
179ec0a049
1 changed files with 11 additions and 9 deletions
|
@ -2,23 +2,25 @@ import factory from '@/__tests__/factory'
|
|||
import { expect, it } from 'vitest'
|
||||
import UnitTestCase from '@/__tests__/UnitTestCase'
|
||||
import AlbumTrackList from './AlbumTrackList.vue'
|
||||
import TrackListItem from './AlbumTrackListItem.vue'
|
||||
import { songStore } from '@/stores'
|
||||
|
||||
new class extends UnitTestCase {
|
||||
protected test () {
|
||||
it('lists the correct number of tracks', () => {
|
||||
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: {
|
||||
album: factory<Album>('album')
|
||||
},
|
||||
global: {
|
||||
stubs: {
|
||||
TrackListItem
|
||||
}
|
||||
album,
|
||||
tracks: factory<AlbumTrack[]>('album-track', 3)
|
||||
}
|
||||
})
|
||||
|
||||
expect(queryAllByTestId('album-track-item')).toHaveLength(2)
|
||||
await this.tick()
|
||||
|
||||
expect(fetchMock).toHaveBeenCalledWith(album)
|
||||
expect(queryAllByTestId('album-track-item')).toHaveLength(3)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue