-
Notifications
You must be signed in to change notification settings - Fork 257
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
Fix set data reactive #540
Changes from 2 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 |
---|---|---|
|
@@ -123,4 +123,43 @@ describe('setData', () => { | |
'Cannot add property count' | ||
) | ||
}) | ||
|
||
it('https://github.com/vuejs/vue-test-utils-next/issues/538', async () => { | ||
const Comp = defineComponent< | ||
{}, | ||
{}, | ||
{ field: number | null }, | ||
{ isFieldNull: any } | ||
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. Unfortunately the type for this is not exported. I thought we had some way to type 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 don't use the Options API, so I don't know... Shouldn't it be 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. According to VS Code it should be I have not used TS with Options API before so I have no idea 🤷♂️ |
||
>({ | ||
template: ` | ||
<div>{{ isFieldNull ? 'It is null' : 'It is not null' }}</div> | ||
`, | ||
data() { | ||
return { | ||
field: null | ||
} | ||
}, | ||
computed: { | ||
isFieldNull() { | ||
return this.field === null | ||
} | ||
} | ||
}) | ||
|
||
const wrapper = mount(Comp, { | ||
data() { | ||
return { | ||
field: null | ||
} | ||
} | ||
}) | ||
|
||
expect(wrapper.vm.isFieldNull).toBe(true) | ||
|
||
await wrapper.setData({ field: 10 }) | ||
await wrapper.vm.$nextTick() | ||
|
||
expect(wrapper.vm.field).toEqual(10) | ||
expect(wrapper.vm.isFieldNull).toBe(false) | ||
}) | ||
}) |
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.
super nit: I prefer when we have a readable test name instead of just a link to a Github issue (easier to understand when the test is failing)
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.
Sure, I'll update