-
Notifications
You must be signed in to change notification settings - Fork 112
Add update method for model updates #34
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
Conversation
references #22 |
Looks good! This made me wonder about the use cases for Should then |
src/vue-testing-library.js
Outdated
|
||
case 'SELECT': | ||
elem.value = value | ||
await fireEvent.change(elem) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quick question! Should this line return
, instead of await
? If not, why does it need to be different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed that, updated now.
WRT change and input, I hadn't considered that update may replace them all. I would rather expose them and allow the user the choice of which to use than deprecate them. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This actually leads me to another question...
I feel that just writing .input
or .change
, like the native events, makes a lot of sense. And it would be quite weird if fireEvent.input
only worked in certain cases (when v-model is not used).
So... what if input
and change
would handle v-model properly, instead of creating a new event? Would it be hard?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could mask input or change, however we're still moving away from what is the idiomatic usage and taking away options from the end user (to use input or change as they are natively).
I'm not sure if there is an ideal solution here tbh, although I think update as it is here is probably the most flexible solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. Also adding a method is a non breaking change, while modifying the implementation of .input
and .change
might be. Let's add the update method and see how it goes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
…ary/vue-testing-library into issues/22-add-update-method
Add update method to handle form updates without having to call updateState