-
Notifications
You must be signed in to change notification settings - Fork 258
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
Bug: Emit doesn't update 2 way bound props #393
Changes from all commits
dece6e4
09a1239
da5872c
a3ad28e
1ef3f86
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { mount } from '../src' | ||
import WithProps from './components/WithProps.vue' | ||
import Hello from './components/Hello.vue' | ||
import { defineComponent } from 'vue' | ||
|
||
describe('props', () => { | ||
it('returns a single prop applied to a component', () => { | ||
|
@@ -82,4 +83,32 @@ describe('props', () => { | |
object: {} | ||
}) | ||
}) | ||
|
||
it('should return the updated props on 2 way binding', async () => { | ||
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. This file is probably the wrong place for this test, please advise where it would be best. 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. Here is probably fine. Probably could re-think the test layout at some point. |
||
const component = defineComponent({ | ||
template: '<button @click="increment"></button>', | ||
props: { | ||
modelValue: { | ||
type: Number, | ||
required: true | ||
} | ||
}, | ||
emits: ['update:modelValue'], | ||
setup(props, ctx) { | ||
return { | ||
increment: () => ctx.emit('update:modelValue', props.modelValue + 1) | ||
} | ||
} | ||
}) | ||
|
||
const wrapper = mount(component, { | ||
props: { | ||
modelValue: 1 | ||
} | ||
}) | ||
|
||
expect(wrapper.props('modelValue')).toBe(1) | ||
await wrapper.trigger('click') | ||
expect(wrapper.props('modelValue')).toBe(2) | ||
}) | ||
}) |
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 I typed wrong in the previous PR, fixed here