koel/resources/assets/js/components/ui/form/CheckBox.spec.ts

25 lines
710 B
TypeScript
Raw Normal View History

2022-07-21 09:32:09 +00:00
import { expect, it } from 'vitest'
import UnitTestCase from '@/__tests__/UnitTestCase'
import { screen } from '@testing-library/vue'
2022-07-21 09:32:09 +00:00
import CheckBox from './CheckBox.vue'
new class extends UnitTestCase {
protected test () {
it('renders unchecked state', () => expect(this.render(CheckBox).html()).toMatchSnapshot())
it('renders checked state', () => expect(this.render(CheckBox, {
props: {
modelValue: true,
},
2022-07-21 09:32:09 +00:00
}).html()).toMatchSnapshot())
it('emits the input event', async () => {
const { emitted } = this.render(CheckBox)
2022-07-21 09:32:09 +00:00
await this.trigger(screen.getByRole('checkbox'), 'click')
2022-07-21 09:32:09 +00:00
expect(emitted()['update:modelValue']).toBeTruthy()
})
}
}