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