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

45 lines
1.4 KiB
TypeScript
Raw Normal View History

2022-10-13 15:18:47 +00:00
import { ref } from 'vue'
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 { albumStore, preferenceStore } from '@/stores'
2022-05-13 17:58:38 +00:00
import UnitTestCase from '@/__tests__/UnitTestCase'
2022-10-13 15:18:47 +00:00
import { CurrentSongKey } from '@/symbols'
import AlbumArtOverlay from '@/components/ui/AlbumArtOverlay.vue'
import MainContent from './MainContent.vue'
2022-05-13 17:58:38 +00:00
new class extends UnitTestCase {
2022-11-06 17:09:06 +00:00
private renderComponent () {
return this.render(MainContent, {
global: {
provide: {
2022-11-06 17:09:06 +00:00
[<symbol>CurrentSongKey]: ref(factory<Song>('song'))
},
stubs: {
AlbumArtOverlay,
HomeScreen: this.stub(), // so that home overview requests are not made
2022-11-06 17:09:06 +00:00
Visualizer: this.stub('visualizer')
}
}
})
}
protected test () {
it('has a translucent overlay per album', async () => {
this.mock(albumStore, 'fetchThumbnail').mockResolvedValue('http://test/foo.jpg')
const { getByTestId } = this.renderComponent()
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.renderComponent()
2022-07-10 14:33:33 +00:00
await waitFor(() => expect(queryByTestId('album-art-overlay')).toBeNull())
})
}
}