-
Notifications
You must be signed in to change notification settings - Fork 668
v-model not reacting to change on element.selected #345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@eddyerburgh Are you working on that or can I try to investigate and implement it ? |
I'm not working on it, it would be great if you could investigate it 😀 |
Didn't find solution (yet), but have a few thoughts - any input about them is welcome:
it worked for me in |
You can solve this by calling it('changes data according to the selected folder option', () => {
wrapperDeep.find('input[type="radio"][value="existing"]').element.selected = true;
wrapperDeep.find('input[type="radio"][value="existing"]').trigger('change')
expect(wrapperDeep.find('.selected').text()).toBe('Selected: existing');
}); |
hi @eddyerburgh sorry to re-open this, but the above workaround doesn't seem to work on checkboxes. That is:
|
There's a PR open that will add a method to set an element checked—https://github.com/vuejs/vue-test-utils/pull/557/files In the PR they set the checked value and trigger a change event, and it works in the test cases in that PR, although in some Vue versions you also need to trigger a click event. |
hey @eddyerburgh thanks for the prompt reply, much appreciated! I'll check out the PR. Thanks again and thank you for this library, it's a godsend! 👍 #offtopic does your book test these kinds of scenarios? 🤔 |
Yes it does 😉 |
I came across a similar issue with setting a value of an input with I fixed it with the custom options on the it('sets amount to zero on invalid input', async () => {
const valueInput = wrapper.get('input[data-testid="value"]')
await valueInput.trigger('change', {
value: ''
})
await wrapper.vm.$nextTick()
expect(valueInput.element.value).toBe('£0.00')
}) |
Simulating selecting radio buttons doesn't seem to be reflected in the model:
Full code with the reproduced example:
https://github.com/folmert/vue-test-utils-jest-example
RadioGroup.vue:
RadioGroup.spec.js:
yarn test
result:The text was updated successfully, but these errors were encountered: