mirror of
https://github.com/koel/koel
synced 2024-12-30 14:33:06 +00:00
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
import { expect, it } from 'vitest'
|
|
import { fireEvent } from '@testing-library/vue'
|
|
import { playbackService } from '@/services'
|
|
import factory from '@/__tests__/factory'
|
|
import UnitTestCase from '@/__tests__/UnitTestCase'
|
|
import FooterPlayerControls from './FooterPlayerControls.vue'
|
|
|
|
new class extends UnitTestCase {
|
|
protected test () {
|
|
it.each<[string, string, MethodOf<typeof playbackService>]>([
|
|
['plays next song', 'Play next song', 'playNext'],
|
|
['plays previous song', 'Play previous song', 'playPrev'],
|
|
['plays/resumes current song', 'Play or resume', 'toggle']
|
|
])('%s', async (_: string, title: string, playbackMethod: MethodOf<typeof playbackService>) => {
|
|
const mock = this.mock(playbackService, playbackMethod)
|
|
|
|
const { getByTitle } = this.render(FooterPlayerControls, {
|
|
props: {
|
|
song: factory<Song>('song')
|
|
}
|
|
})
|
|
|
|
await fireEvent.click(getByTitle(title))
|
|
expect(mock).toHaveBeenCalled()
|
|
})
|
|
|
|
it('pauses the current song', async () => {
|
|
const mock = this.mock(playbackService, 'toggle')
|
|
|
|
const { getByTitle } = this.render(FooterPlayerControls, {
|
|
props: {
|
|
song: factory<Song>('song', {
|
|
playback_state: 'Playing'
|
|
})
|
|
}
|
|
})
|
|
|
|
await fireEvent.click(getByTitle('Pause'))
|
|
expect(mock).toHaveBeenCalled()
|
|
})
|
|
}
|
|
}
|