feat(test): add RepeatModeSwitch component tests

This commit is contained in:
Phan An 2022-05-11 19:10:18 +02:00
parent 3a4eda4ab8
commit 45669aa9de
No known key found for this signature in database
GPG key ID: A81E4477F0BB6FDC

View file

@ -0,0 +1,20 @@
import { expect, it } from 'vitest'
import { preferenceStore } from '@/stores'
import ComponentTestCase from '@/__tests__/ComponentTestCase'
import RepeatModeSwitch from './RepeatModeSwitch.vue'
import { fireEvent } from '@testing-library/vue'
import { playbackService } from '@/services'
new class extends ComponentTestCase {
protected test () {
it('changes mode', async () => {
const mock = this.mock(playbackService, 'changeRepeatMode')
preferenceStore.state.repeatMode = 'NO_REPEAT'
const { getByRole } = this.render(RepeatModeSwitch)
await fireEvent.click(getByRole('button'))
expect(mock).toHaveBeenCalledOnce()
})
}
}