mirror of
https://github.com/koel/koel
synced 2024-12-20 09:33:23 +00:00
39 lines
914 B
TypeScript
39 lines
914 B
TypeScript
|
import { screen } from '@testing-library/vue'
|
||
|
import { expect, it } from 'vitest'
|
||
|
import UnitTestCase from '@/__tests__/UnitTestCase'
|
||
|
import Component from './EpisodeItem.vue'
|
||
|
import factory from '@/__tests__/factory'
|
||
|
import { playbackService } from '@/services'
|
||
|
|
||
|
new class extends UnitTestCase {
|
||
|
private renderComponent (episode: Episode, podcast?: Podcast) {
|
||
|
podcast = podcast || factory('podcast', {
|
||
|
id: episode.id
|
||
|
})
|
||
|
|
||
|
this.render(Component, {
|
||
|
props: {
|
||
|
episode,
|
||
|
podcast
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
|
||
|
protected test () {
|
||
|
it('pauses playback', async () => {
|
||
|
const pauseMock = this.mock(playbackService, 'pause')
|
||
|
|
||
|
const episode = factory('episode', {
|
||
|
id: 'foo',
|
||
|
playback_state: 'Playing'
|
||
|
})
|
||
|
|
||
|
this.renderComponent(episode)
|
||
|
|
||
|
await this.user.click(screen.getByRole('button'))
|
||
|
|
||
|
expect(pauseMock).toHaveBeenCalled()
|
||
|
})
|
||
|
}
|
||
|
}
|