2022-07-10 16:12:04 +00:00
|
|
|
import { expect, it } from 'vitest'
|
|
|
|
import UnitTestCase from '@/__tests__/UnitTestCase'
|
|
|
|
import factory from '@/__tests__/factory'
|
|
|
|
import { fireEvent } from '@testing-library/vue'
|
|
|
|
import router from '@/router'
|
2022-09-15 09:07:25 +00:00
|
|
|
import { overviewStore } from '@/stores'
|
|
|
|
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-07-10 16:12:04 +00:00
|
|
|
expect(this.render(RecentlyPlayedSongs).getAllByTestId('song-card')).toHaveLength(6)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('goes to dedicated screen', async () => {
|
|
|
|
const mock = this.mock(router, 'go')
|
|
|
|
const { getByTestId } = this.render(RecentlyPlayedSongs)
|
|
|
|
|
|
|
|
await fireEvent.click(getByTestId('home-view-all-recently-played-btn'))
|
|
|
|
|
|
|
|
expect(mock).toHaveBeenCalledWith('recently-played')
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|