Skip to content

Commit 363e5e5

Browse files
Add test for update method being called after component has been destroyed
1 parent 51515b3 commit 363e5e5

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,3 +1048,28 @@ test("$asyncComputed[name].state resolves to 'success' even if the computed valu
10481048
t.equal(vm.isUpdating, false)
10491049
})
10501050
})
1051+
1052+
test("$asyncComputed[name].update does nothing if called after the component is destroyed", t => {
1053+
t.plan(4)
1054+
let i = 0
1055+
const vm = new Vue({
1056+
asyncComputed: {
1057+
a: {
1058+
async get () {
1059+
return ++i
1060+
}
1061+
}
1062+
}
1063+
})
1064+
1065+
t.equal(vm.a, null)
1066+
Vue.nextTick(() => {
1067+
t.equal(vm.a, 1)
1068+
vm.$destroy()
1069+
vm.$asyncComputed.a.update()
1070+
Vue.nextTick(() => {
1071+
t.equal(i, 1)
1072+
t.equal(vm.a, 1)
1073+
})
1074+
})
1075+
})

0 commit comments

Comments
 (0)