21 lines
767 B
TypeScript
21 lines
767 B
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { mount } from '@vue/test-utils'
|
|
import { Checkbox } from '../src/lib'
|
|
|
|
describe('Checkbox', () => {
|
|
it('renders unchecked by default', () => {
|
|
const wrapper = mount(Checkbox)
|
|
expect(wrapper.get('button').attributes('data-state')).toBe('unchecked')
|
|
})
|
|
|
|
it('reflects modelValue as checked', () => {
|
|
const wrapper = mount(Checkbox, { props: { modelValue: true } })
|
|
expect(wrapper.get('button').attributes('data-state')).toBe('checked')
|
|
})
|
|
|
|
it('emits update:modelValue on click', async () => {
|
|
const wrapper = mount(Checkbox, { props: { modelValue: false } })
|
|
await wrapper.get('button').trigger('click')
|
|
expect(wrapper.emitted('update:modelValue')?.[0]).toEqual([true])
|
|
})
|
|
})
|