Skip to content

Commit 771075f

Browse files
committed
test: ensure Wrapper.setChecked() is a no-op for checked checkboxes
1 parent 7c7b949 commit 771075f

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

test/specs/wrapper/setChecked.spec.js

+23-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,28 @@ describeWithShallowAndMount('setChecked', mountingMethod => {
5555
expect(wrapper.find('.counter').text()).to.equal('4')
5656
})
5757

58+
it('should trigger a change event when called on a checkbox', () => {
59+
const listeners = { change: sinon.spy() }
60+
const input = mountingMethod({
61+
template: `<input type="checkbox" v-on="$listeners">`,
62+
}, { listeners })
63+
64+
input.setChecked()
65+
66+
expect(listeners.change).to.have.been.called
67+
});
68+
69+
it('should not trigger a change event if the checkbox is already checked', () => {
70+
const listeners = { change: sinon.spy() }
71+
const input = mountingMethod({
72+
template: `<input type="checkbox" checked v-on="$listeners">`,
73+
}, { listeners })
74+
75+
input.setChecked()
76+
77+
expect(listeners.change).not.to.have.been.called
78+
});
79+
5880
it('updates dom with radio v-model', async () => {
5981
const wrapper = mountingMethod(ComponentWithInput)
6082

@@ -67,7 +89,7 @@ describeWithShallowAndMount('setChecked', mountingMethod => {
6789
expect(wrapper.text()).to.contain('radioFooResult')
6890
})
6991

70-
it('changes state the right amount of times with checkbox v-model', async () => {
92+
it('changes state the right amount of times with radio v-model', async () => {
7193
const wrapper = mountingMethod(ComponentWithInput)
7294
const radioBar = wrapper.find('#radioBar')
7395
const radioFoo = wrapper.find('#radioFoo')

0 commit comments

Comments
 (0)