Skip to content

Commit 36ec8ed

Browse files
committed
Add checkbox tests
1 parent cba9667 commit 36ec8ed

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/components/primitives/Checkbox/Checkbox.spec.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,27 @@ describe('Checkbox', () => {
1515
it('render correctly', () => {
1616
expect(wrapper.html()).toMatchSnapshot()
1717
})
18+
19+
it('has an input checkbox', () => {
20+
expect(wrapper.html()).toContain('input type="checkbox"')
21+
})
22+
23+
it('emit input event with value when value change', async () => {
24+
wrapper.setProps({ modelValue: true })
25+
await wrapper.vm.$nextTick()
26+
expect(wrapper.vm.value).toBeTruthy()
27+
28+
wrapper.vm.value = false
29+
await wrapper.vm.$nextTick()
30+
31+
const valueEmitted = wrapper.emitted()['update:modelValue'][2]
32+
expect(valueEmitted).toContainEqual(false)
33+
})
34+
35+
it('method focus() gives focus to the input element', async () => {
36+
wrapper.vm.$refs.input.focus = jest.fn()
37+
wrapper.vm.focus()
38+
await wrapper.vm.$nextTick()
39+
expect(wrapper.vm.$refs.input.focus).toHaveBeenCalledTimes(1)
40+
})
1841
})

0 commit comments

Comments
 (0)