koel/resources/assets/js/components/layout/main-wrapper/MainContent.spec.ts

61 lines
1.7 KiB
TypeScript
Raw Normal View History

2022-07-10 14:33:33 +00:00
import { waitFor } from '@testing-library/vue'
import { expect, it } from 'vitest'
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'
import MainContent from '@/components/layout/main-wrapper/MainContent.vue'
import AlbumArtOverlay from '@/components/ui/AlbumArtOverlay.vue'
2022-05-13 17:58:38 +00:00
new class extends UnitTestCase {
protected test () {
it('has a translucent overlay per album', async () => {
2022-07-10 14:33:33 +00:00
this.mock(albumStore, 'fetchThumbnail').mockResolvedValue('https://foo/bar.jpg')
const { getByTestId } = this.render(MainContent, {
global: {
stubs: {
AlbumArtOverlay
}
}
})
eventBus.emit('SONG_STARTED', factory<Song>('song'))
2022-07-10 14:33:33 +00:00
await waitFor(() => getByTestId('album-art-overlay'))
})
it('does not have a translucent over if configured not so', async () => {
preferenceStore.state.showAlbumArtOverlay = false
const { queryByTestId } = this.render(MainContent, {
global: {
stubs: {
AlbumArtOverlay
}
}
})
eventBus.emit('SONG_STARTED', factory<Song>('song'))
2022-07-10 14:33:33 +00:00
await waitFor(() => expect(queryByTestId('album-art-overlay')).toBeNull())
})
it('toggles visualizer', async () => {
const { getByTestId, queryByTestId } = this.render(MainContent, {
global: {
stubs: {
2022-07-10 14:33:33 +00:00
Visualizer: this.stub('visualizer')
}
}
})
eventBus.emit('TOGGLE_VISUALIZER')
2022-07-10 14:33:33 +00:00
await waitFor(() => getByTestId('visualizer'))
eventBus.emit('TOGGLE_VISUALIZER')
2022-07-10 14:33:33 +00:00
await waitFor(() => expect(queryByTestId('visualizer')).toBeNull())
})
}
}