-
Notifications
You must be signed in to change notification settings - Fork 668
Change the way of setting props #1300
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<script> | ||
export default { | ||
props: ['prop1'], | ||
data: function() { | ||
return { | ||
data1: null | ||
} | ||
}, | ||
|
||
watch: { | ||
prop1: { | ||
handler() { | ||
this.data1 = this.prop1 | ||
}, | ||
immediate: true | ||
} | ||
} | ||
} | ||
</script> | ||
<template> | ||
<h1>test</h1> | ||
</template> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { compileToFunctions } from 'vue-template-compiler' | ||
import ComponentWithProps from '~resources/components/component-with-props.vue' | ||
import ComponentWithWatch from '~resources/components/component-with-watch.vue' | ||
import ComponentWithWatchImmediate from '~resources/components/component-with-watch-immediate.vue' | ||
import { describeWithShallowAndMount, vueVersion } from '~resources/utils' | ||
import { itDoNotRunIf } from 'conditional-specs' | ||
import Vue from 'vue' | ||
|
@@ -244,6 +245,17 @@ describeWithShallowAndMount('setProps', mountingMethod => { | |
expect(wrapper.vm.propA).to.equal('value') | ||
}) | ||
|
||
it('correctly sets props in async mode when component has immediate watchers', async () => { | ||
const wrapper = mountingMethod(ComponentWithWatchImmediate, { | ||
sync: false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I might be missing something here, but I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I pulled it out of the src. That's a typo. Thanks for the catch |
||
}) | ||
|
||
const prop1 = 'testest' | ||
wrapper.setProps({ prop1 }) | ||
await Vue.nextTick() | ||
expect(wrapper.vm.prop1).to.equal(prop1) | ||
}) | ||
|
||
it('throws an error if node is not a Vue instance', () => { | ||
const message = 'wrapper.setProps() can only be called on a Vue instance' | ||
const compiled = compileToFunctions('<div><p></p></div>') | ||
|
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 think we can remove this, sync mode is gone now.