2022-05-08 18:43:52 +00:00
|
|
|
import factory from '@/__tests__/factory'
|
2022-05-09 09:59:31 +00:00
|
|
|
import { expect, it } from 'vitest'
|
|
|
|
import { fireEvent } from '@testing-library/vue'
|
2022-05-13 17:58:38 +00:00
|
|
|
import UnitTestCase from '@/__tests__/UnitTestCase'
|
2022-08-10 14:56:01 +00:00
|
|
|
import PlaylistSidebarItem from './PlaylistSidebarItem.vue'
|
2022-05-08 18:43:52 +00:00
|
|
|
|
2022-05-13 17:58:38 +00:00
|
|
|
new class extends UnitTestCase {
|
2022-05-09 09:59:31 +00:00
|
|
|
renderComponent (playlist: Record<string, any>, type: PlaylistType = 'playlist') {
|
|
|
|
return this.render(PlaylistSidebarItem, {
|
|
|
|
props: {
|
|
|
|
playlist,
|
|
|
|
type
|
2022-05-08 18:43:52 +00:00
|
|
|
}
|
2022-05-09 09:59:31 +00:00
|
|
|
})
|
|
|
|
}
|
2022-05-08 18:43:52 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
protected test () {
|
|
|
|
it('edits the name of a standard playlist', async () => {
|
|
|
|
const { getByTestId, queryByTestId } = this.renderComponent(factory<Playlist>('playlist', {
|
|
|
|
id: 99,
|
|
|
|
name: 'A Standard Playlist'
|
|
|
|
}))
|
2022-05-08 18:43:52 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
expect(await queryByTestId('name-editor')).toBeNull()
|
2022-05-08 18:43:52 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
await fireEvent.dblClick(getByTestId('playlist-sidebar-item'))
|
2022-05-08 18:43:52 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
getByTestId('name-editor')
|
|
|
|
})
|
2022-05-08 18:43:52 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
it('does not allow editing the name of the "Favorites" playlist', async () => {
|
|
|
|
const { getByTestId, queryByTestId } = this.renderComponent({
|
|
|
|
name: 'Favorites',
|
|
|
|
songs: []
|
|
|
|
}, 'favorites')
|
2022-05-08 18:43:52 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
expect(await queryByTestId('name-editor')).toBeNull()
|
2022-05-08 18:43:52 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
await fireEvent.dblClick(getByTestId('playlist-sidebar-item'))
|
2022-05-08 18:43:52 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
expect(await queryByTestId('name-editor')).toBeNull()
|
|
|
|
})
|
2022-05-08 18:43:52 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
it('does not allow editing the name of the "Recently Played" playlist', async () => {
|
|
|
|
const { getByTestId, queryByTestId } = this.renderComponent({
|
|
|
|
name: 'Recently Played',
|
|
|
|
songs: []
|
|
|
|
}, 'recently-played')
|
2022-05-08 18:43:52 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
expect(await queryByTestId('name-editor')).toBeNull()
|
2022-05-08 18:43:52 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
await fireEvent.dblClick(getByTestId('playlist-sidebar-item'))
|
|
|
|
|
|
|
|
expect(await queryByTestId('name-editor')).toBeNull()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|