koel/resources/assets/js/components/profile-preferences/ThemeCard.spec.ts

32 lines
744 B
TypeScript
Raw Normal View History

2022-05-13 17:58:38 +00:00
import UnitTestCase from '@/__tests__/UnitTestCase'
import { expect, it } from 'vitest'
import { screen } from '@testing-library/vue'
import ThemeCard from './ThemeCard.vue'
const theme: Theme = {
id: 'sample',
thumbnailColor: '#f00',
}
2022-05-13 17:58:38 +00:00
new class extends UnitTestCase {
protected test () {
it('renders', () => expect(this.renderComponent().html()).toMatchSnapshot())
it('emits an event when selected', async () => {
const { emitted } = this.renderComponent()
await this.user.click(screen.getByRole('button', { name: 'Sample' }))
expect(emitted().selected[0]).toEqual([theme])
})
}
2024-04-23 21:01:27 +00:00
private renderComponent () {
return this.render(ThemeCard, {
props: {
theme,
},
2024-04-23 21:01:27 +00:00
})
}
}