Skip to content

Commit b5a8092

Browse files
New (more robust) setup for testing promise rejections in async computed properties
1 parent f8bd9d4 commit b5a8092

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

test/index.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@ import test from "tape"
22
import AsyncComputed from "../src"
33
import Vue from 'vue'
44

5-
const testErrorLog = []
5+
let baseErrorCallback = () => {
6+
throw new Error('Unexpected error thrown')
7+
}
8+
9+
let testErrorCallback = baseErrorCallback
10+
611
Vue.use(AsyncComputed, {
7-
errorHandler: msg => testErrorLog.push(msg)
12+
errorHandler: msg => testErrorCallback(msg)
813
})
914

1015
test("Async computed values get computed", t => {
@@ -150,7 +155,7 @@ test("Having only sync computed data still works", t => {
150155
})
151156

152157
test("Handle errors in computed properties", t => {
153-
t.plan(4)
158+
t.plan(2)
154159
const vm = new Vue({
155160
asyncComputed: {
156161
a () {
@@ -159,15 +164,10 @@ test("Handle errors in computed properties", t => {
159164
}
160165
})
161166
t.equal(vm.a, null)
162-
t.equal(testErrorLog.length, 0)
163-
Vue.nextTick(() =>
164-
// In Vue 2.0 it takes an additional tick before
165-
// we see the error
166-
Vue.nextTick(() => {
167-
t.equal(vm.a, null)
168-
t.equal(testErrorLog.length, 1)
169-
})
170-
)
167+
testErrorCallback = msg => {
168+
t.equal(vm.a, null)
169+
testErrorCallback = baseErrorCallback
170+
}
171171
})
172172

173173
test("Handle multiple asyncComputed objects the same way normal as \

0 commit comments

Comments
 (0)