Skip to content

Commit 6671b01

Browse files
committed
Fixing prototype methods being discarded when using setData
1 parent 83855a0 commit 6671b01

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

‎tests/setData.spec.ts‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ describe('setData', () => {
218218
it('should retain prototype methods for constructed objects when calling setData', async () => {
219219
const expectedResult = 'success!'
220220
class TestClass {
221-
getResult() {
221+
constructor(readonly name: string) {}
222+
getResult(): string {
222223
return expectedResult
223224
}
224225
}
@@ -227,22 +228,22 @@ describe('setData', () => {
227228
defineComponent({
228229
template: '<div/>',
229230
data() {
230-
return { value: new TestClass() }
231+
return { value: new TestClass('test1') }
231232
},
232233
methods: {
233234
getResult() {
234-
return this.value.getResult()
235+
return `${this.value.name}: ${this.value.getResult()}`
235236
}
236237
}
237238
})
238239
)
239240

240-
expect(wrapper.vm.getResult()).toStrictEqual(expectedResult)
241+
expect(wrapper.vm.getResult()).toStrictEqual(`test1: ${expectedResult}`)
241242

242243
await wrapper.setData({
243-
value: new TestClass()
244+
value: new TestClass('test2')
244245
})
245246

246-
expect(wrapper.vm.getResult()).toStrictEqual(expectedResult)
247+
expect(wrapper.vm.getResult()).toStrictEqual(`test2: ${expectedResult}`)
247248
})
248249
})

0 commit comments

Comments
 (0)