2022-07-10 14:33:33 +00:00
|
|
|
import { waitFor } from '@testing-library/vue'
|
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-13 17:58:38 +00:00
|
|
|
import UnitTestCase from '@/__tests__/UnitTestCase'
|
2022-05-06 15:52:37 +00:00
|
|
|
import AlbumArtOverlay from '@/components/ui/AlbumArtOverlay.vue'
|
2022-09-12 15:33:41 +00:00
|
|
|
import MainContent from './MainContent.vue'
|
2022-05-06 15:52:37 +00:00
|
|
|
|
2022-05-13 17:58:38 +00:00
|
|
|
new class extends UnitTestCase {
|
2022-05-09 09:59:31 +00:00
|
|
|
protected test () {
|
|
|
|
it('has a translucent overlay per album', async () => {
|
2022-09-12 15:33:41 +00:00
|
|
|
this.mock(albumStore, 'fetchThumbnail').mockResolvedValue('http://localhost/foo.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'))
|
2022-05-06 15:52:37 +00:00
|
|
|
|
2022-07-10 14:33:33 +00:00
|
|
|
await waitFor(() => getByTestId('album-art-overlay'))
|
2022-05-09 09:59:31 +00:00
|
|
|
})
|
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'))
|
2022-05-06 15:52:37 +00:00
|
|
|
|
2022-07-10 14:33:33 +00:00
|
|
|
await waitFor(() => expect(queryByTestId('album-art-overlay')).toBeNull())
|
2022-05-09 09:59:31 +00:00
|
|
|
})
|
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: {
|
2022-07-10 14:33:33 +00:00
|
|
|
Visualizer: this.stub('visualizer')
|
2022-05-09 09:59:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2022-05-06 15:52:37 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
eventBus.emit('TOGGLE_VISUALIZER')
|
2022-07-10 14:33:33 +00:00
|
|
|
await waitFor(() => getByTestId('visualizer'))
|
2022-05-06 15:52:37 +00:00
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
eventBus.emit('TOGGLE_VISUALIZER')
|
2022-07-10 14:33:33 +00:00
|
|
|
await waitFor(() => expect(queryByTestId('visualizer')).toBeNull())
|
2022-05-09 09:59:31 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|