2022-05-09 09:59:31 +00:00
|
|
|
import { it } from 'vitest'
|
2022-09-08 05:06:49 +00:00
|
|
|
import { playlistFolderStore, playlistStore } from '@/stores'
|
2022-05-09 08:14:56 +00:00
|
|
|
import factory from '@/__tests__/factory'
|
2022-09-08 05:06:49 +00:00
|
|
|
import UnitTestCase from '@/__tests__/UnitTestCase'
|
2022-05-09 08:14:56 +00:00
|
|
|
import PlaylistSidebarList from './PlaylistSidebarList.vue'
|
|
|
|
import PlaylistSidebarItem from './PlaylistSidebarItem.vue'
|
2022-09-08 05:06:49 +00:00
|
|
|
import PlaylistFolderSidebarItem from './PlaylistFolderSidebarItem.vue'
|
2022-05-09 08:14:56 +00:00
|
|
|
|
2022-05-13 17:58:38 +00:00
|
|
|
new class extends UnitTestCase {
|
2022-09-08 05:06:49 +00:00
|
|
|
private renderComponent () {
|
|
|
|
return this.render(PlaylistSidebarList, {
|
|
|
|
global: {
|
|
|
|
stubs: {
|
|
|
|
PlaylistSidebarItem,
|
|
|
|
PlaylistFolderSidebarItem
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
protected test () {
|
2022-09-08 05:06:49 +00:00
|
|
|
it('displays orphan playlists', () => {
|
2022-05-09 09:59:31 +00:00
|
|
|
playlistStore.state.playlists = [
|
2022-09-08 05:06:49 +00:00
|
|
|
factory.states('orphan')<Playlist>('playlist', { name: 'Foo Playlist' }),
|
|
|
|
factory.states('orphan')<Playlist>('playlist', { name: 'Bar Playlist' }),
|
|
|
|
factory.states('smart', 'orphan')<Playlist>('playlist', { name: 'Smart Playlist' })
|
2022-05-09 09:59:31 +00:00
|
|
|
]
|
2022-05-09 08:14:56 +00:00
|
|
|
|
2022-09-08 05:06:49 +00:00
|
|
|
const { getByText } = this.renderComponent()
|
2022-05-09 08:14:56 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
;['Favorites', 'Recently Played', 'Foo Playlist', 'Bar Playlist', 'Smart Playlist'].forEach(t => getByText(t))
|
2022-05-09 08:14:56 +00:00
|
|
|
})
|
|
|
|
|
2022-09-08 05:06:49 +00:00
|
|
|
it('displays playlist folders', () => {
|
|
|
|
playlistFolderStore.state.folders = [
|
|
|
|
factory<PlaylistFolder>('playlist-folder', { name: 'Foo Folder' }),
|
|
|
|
factory<PlaylistFolder>('playlist-folder', { name: 'Bar Folder' })
|
|
|
|
]
|
|
|
|
|
|
|
|
const { getByText } = this.renderComponent()
|
|
|
|
;['Foo Folder', 'Bar Folder'].forEach(t => getByText(t))
|
|
|
|
})
|
2022-05-09 09:59:31 +00:00
|
|
|
}
|
|
|
|
}
|