Skip to content

Commit cde4f9d

Browse files
regouyyx990803
authored andcommitted
fix: should throw error (#55)
1 parent 56bbffd commit cde4f9d

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

Diff for: src/mixin.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default {
4646
}
4747
vm._obSubscriptions.push(obs[key].subscribe(value => {
4848
vm[key] = value
49-
}))
49+
}, (error) => { throw error }))
5050
})
5151
}
5252
},

Diff for: test/test.js

+23
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,29 @@ test('subscriptions() has access to component state', () => {
117117
expect(vm.$el.textContent).toBe('FOOBAR')
118118
})
119119

120+
test('subscriptions() can throw error properly', done => {
121+
const { ob, next } = mock()
122+
123+
const vm = new Vue({
124+
subscriptions () {
125+
return {
126+
num: ob.startWith(1).map(n => n.toFixed())
127+
}
128+
},
129+
render (h) {
130+
return h('div', this.num)
131+
}
132+
}).$mount()
133+
134+
nextTick(() => {
135+
expect(() => {
136+
next(null)
137+
}).toThrow()
138+
expect(vm.$el.textContent).toBe('1')
139+
done()
140+
})
141+
})
142+
120143
test('v-stream directive (basic)', done => {
121144
const vm = new Vue({
122145
template: `

0 commit comments

Comments
 (0)