2022-07-10 16:12:04 +00:00
|
|
|
import { expect, it } from 'vitest'
|
|
|
|
import UnitTestCase from '@/__tests__/UnitTestCase'
|
|
|
|
import factory from '@/__tests__/factory'
|
2022-09-15 09:07:25 +00:00
|
|
|
import { overviewStore } from '@/stores'
|
2022-11-29 10:18:58 +00:00
|
|
|
import { screen } from '@testing-library/vue'
|
2022-09-15 09:07:25 +00:00
|
|
|
import RecentlyPlayedSongs from './RecentlyPlayedSongs.vue'
|
2022-07-10 16:12:04 +00:00
|
|
|
|
|
|
|
new class extends UnitTestCase {
|
|
|
|
protected test () {
|
|
|
|
it('displays the songs', () => {
|
2022-09-15 09:07:25 +00:00
|
|
|
overviewStore.state.recentlyPlayed = factory<Song>('song', 6)
|
2022-11-29 10:18:58 +00:00
|
|
|
expect(this.render(RecentlyPlayedSongs, {
|
|
|
|
global: {
|
|
|
|
stubs: {
|
|
|
|
SongCard: this.stub('song-card')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).getAllByTestId('song-card')).toHaveLength(6)
|
2022-07-10 16:12:04 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('goes to dedicated screen', async () => {
|
2022-10-08 10:54:25 +00:00
|
|
|
const mock = this.mock(this.router, 'go')
|
2022-11-29 10:18:58 +00:00
|
|
|
this.render(RecentlyPlayedSongs)
|
2022-07-10 16:12:04 +00:00
|
|
|
|
2022-11-29 10:18:58 +00:00
|
|
|
await this.user.click(screen.getByRole('button', { name: 'View All' }))
|
2022-07-10 16:12:04 +00:00
|
|
|
|
|
|
|
expect(mock).toHaveBeenCalledWith('recently-played')
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|