2024-01-18 11:13:05 +00:00
|
|
|
import Router from '@/router'
|
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', () => {
|
2024-06-01 18:02:27 +00:00
|
|
|
overviewStore.state.recentlyPlayed = factory('song', 6)
|
2022-11-29 10:18:58 +00:00
|
|
|
expect(this.render(RecentlyPlayedSongs, {
|
|
|
|
global: {
|
|
|
|
stubs: {
|
2024-10-13 17:37:01 +00:00
|
|
|
SongCard: this.stub('song-card'),
|
|
|
|
},
|
|
|
|
},
|
2022-11-29 10:18:58 +00:00
|
|
|
}).getAllByTestId('song-card')).toHaveLength(6)
|
2022-07-10 16:12:04 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('goes to dedicated screen', async () => {
|
2024-01-18 11:13:05 +00:00
|
|
|
const mock = this.mock(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')
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|