2022-05-09 09:59:31 +00:00
|
|
|
import { expect, it } from 'vitest'
|
2022-05-06 15:52:37 +00:00
|
|
|
import factory from '@/__tests__/factory'
|
|
|
|
import { eventBus } from '@/utils'
|
|
|
|
import { albumStore, preferenceStore } from '@/stores'
|
2022-05-09 09:59:31 +00:00
|
|
|
import ComponentTestCase from '@/__tests__/ComponentTestCase'
|
2022-05-06 15:52:37 +00:00
|
|
|
import MainContent from '@/components/layout/main-wrapper/MainContent.vue'
|
|
|
|
import AlbumArtOverlay from '@/components/ui/AlbumArtOverlay.vue'
|
|
|
|
import Visualizer from '@/components/ui/Visualizer.vue'
|
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
new class extends ComponentTestCase {
|
|
|
|
protected test () {
|
|
|
|
it('has a translucent overlay per album', async () => {
|
|
|
|
this.mock(albumStore, 'getThumbnail', 'https://foo/bar.jpg')
|
2022-05-06 15:52:37 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
const { getByTestId } = this.render(MainContent, {
|
|
|
|
global: {
|
|
|
|
stubs: {
|
|
|
|
AlbumArtOverlay
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2022-05-06 15:52:37 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
eventBus.emit('SONG_STARTED', factory<Song>('song'))
|
|
|
|
await this.tick(2) // re-render and fetch album thumbnail
|
2022-05-06 15:52:37 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
getByTestId('album-art-overlay')
|
|
|
|
})
|
2022-05-06 15:52:37 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
it('does not have a translucent over if configured not so', async () => {
|
|
|
|
preferenceStore.state.showAlbumArtOverlay = false
|
2022-05-06 15:52:37 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
const { queryByTestId } = this.render(MainContent, {
|
|
|
|
global: {
|
|
|
|
stubs: {
|
|
|
|
AlbumArtOverlay
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2022-05-06 15:52:37 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
eventBus.emit('SONG_STARTED', factory<Song>('song'))
|
|
|
|
await this.tick(2) // re-render and fetch album thumbnail
|
2022-05-06 15:52:37 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
expect(await queryByTestId('album-art-overlay')).toBeNull()
|
|
|
|
})
|
2022-05-06 15:52:37 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
it('toggles visualizer', async () => {
|
|
|
|
const { getByTestId, queryByTestId } = this.render(MainContent, {
|
|
|
|
global: {
|
|
|
|
stubs: {
|
|
|
|
Visualizer
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2022-05-06 15:52:37 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
eventBus.emit('TOGGLE_VISUALIZER')
|
|
|
|
await this.tick()
|
|
|
|
getByTestId('visualizer')
|
2022-05-06 15:52:37 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
eventBus.emit('TOGGLE_VISUALIZER')
|
|
|
|
await this.tick()
|
|
|
|
expect(await queryByTestId('visualizer')).toBeNull()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|