Skip to content

Commit e229e37

Browse files
committed
test: ensure Wrapper.setSelected() idempotency
1 parent f63eda2 commit e229e37

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Diff for: test/specs/wrapper/setSelected.spec.js

+32
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,38 @@ describeWithShallowAndMount('setSelected', mountingMethod => {
3939
expect(wrapper.text()).to.contain('selectA')
4040
})
4141

42+
it('should trigger a change event on the parent <select>', () => {
43+
const change = sinon.spy()
44+
45+
mountingMethod({
46+
template: `
47+
<select @change="change">
48+
<option />
49+
<option value="foo" />
50+
</select>
51+
`,
52+
methods: { change },
53+
}).findAll('option').at(1).setSelected()
54+
55+
expect(change).to.have.been.called
56+
});
57+
58+
it('should not trigger an event if already selected', () => {
59+
const change = sinon.spy()
60+
61+
mountingMethod({
62+
template: `
63+
<select @change="change">
64+
<option />
65+
<option selected value="foo" />
66+
</select>
67+
`,
68+
methods: { change },
69+
}).findAll('option').at(1).setSelected()
70+
71+
expect(change).not.to.have.been.called
72+
});
73+
4274
it('throws error if element is not valid', () => {
4375
const message = 'wrapper.setSelected() cannot be called on this element'
4476

0 commit comments

Comments
 (0)