🌐 AI搜索 & 代理 主页
Skip to content

Commit a07b4ba

Browse files
authored
Update table-provider.spec.js
1 parent b5d6d3a commit a07b4ba

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

���src/components/table/table-provider.spec.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -322,16 +322,18 @@ describe('table > provider functions', () => {
322322
lastProviderContext = ctx
323323
return testItems.slice()
324324
}
325+
// We need a wrapper app to get around a "bug" in Vue test utils that
326+
// doesn't let us change a child property in an object and update
327+
// that prop with the same object reference
328+
// https://forum.vuejs.org/t/vue-test-utils-watchers-on-object-properties-not-triggered/50900/11?u=tmorehouse
325329
const App = {
326-
data {
327-
// We use `this.$data` to get around a "bug" in Vue test utils that
328-
// doesn't let us change a child property in an object and update
329-
//that prop with the same object reference
330-
// https://forum.vuejs.org/t/vue-test-utils-watchers-on-object-properties-not-triggered/50900/11?u=tmorehouse
331-
a: '123'
330+
data: {
331+
filter: {
332+
a: '123'
333+
}
332334
},
333335
render(h) {
334-
h(BTable, { props: { filter: this.$data, items: provider } })
336+
h(BTable, { props: { filter: this.filter, items: provider } })
335337
}
336338
}
337339

@@ -340,18 +342,14 @@ describe('table > provider functions', () => {
340342
await waitNT(wrapper.vm)
341343
await waitNT(wrapper.vm)
342344
await waitNT(wrapper.vm)
343-
expect(wrapper.$data).toEqual({
344-
a: '123'
345-
})
346345

347346
expect(lastProviderContext.filter).toEqual({
348347
a: '123'
349348
})
350349

351350
// Change the filter criteria child property, but not the object reference
352-
wrapper.setData({
353-
a: '456'
354-
})
351+
// `setData` recursivly traverses the object and only changes the leaf values
352+
wrapper.setData({ filter: { a: '456' } })
355353

356354
await waitNT(wrapper.vm)
357355
await waitNT(wrapper.vm)

0 commit comments

Comments
 (0)