koel/resources/assets/js/components/podcast/AddPodcastForm.spec.ts
2024-07-06 17:45:07 +02:00

18 lines
754 B
TypeScript

import { screen } from '@testing-library/vue'
import { expect, it } from 'vitest'
import UnitTestCase from '@/__tests__/UnitTestCase'
import { podcastStore } from '@/stores'
import Component from './AddPodcastForm.vue'
import factory from '@/__tests__/factory'
new class extends UnitTestCase {
protected test () {
it('adds a new podcast', async() => {
const storeMock = this.mock(podcastStore, 'store').mockResolvedValue(factory('podcast'))
this.render(Component)
await this.type(screen.getByPlaceholderText('https://example.com/feed.xml'), 'https://foo.bar/feed.xml')
await this.user.click(screen.getByRole('button', { name: 'Save' }))
expect(storeMock).toHaveBeenCalledWith('https://foo.bar/feed.xml')
})
}
}