Skip to content

Commit 6300551

Browse files
committed
test: Provide option not getting merged from mixins
1 parent 8ff77a2 commit 6300551

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

test/unit/features/options/inject.spec.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,4 +298,44 @@ describe('Options provide/inject', () => {
298298
expect(`Injection "bar" not found`).not.toHaveBeenWarned()
299299
expect(`Injection "baz" not found`).not.toHaveBeenWarned()
300300
})
301+
302+
// Github issue #6008
303+
it('should merge provide from mixins', () => {
304+
const mixinA = { provide: { foo: 'foo' }}
305+
const mixinB = { provide: { bar: 'bar' }}
306+
const child = {
307+
inject: ['foo', 'bar'],
308+
template: `<span/>`,
309+
created () {
310+
injected = [this.foo, this.bar]
311+
}
312+
}
313+
new Vue({
314+
mixins: [mixinA, mixinB],
315+
render (h) {
316+
return h(child)
317+
}
318+
}).$mount()
319+
320+
expect(injected).toEqual(['foo', 'bar'])
321+
})
322+
it('should merge provide from mixins and override existing keys', () => {
323+
const mixinA = { provide: { foo: 'foo' }}
324+
const mixinB = { provide: { foo: 'bar' }}
325+
const child = {
326+
inject: ['foo'],
327+
template: `<span/>`,
328+
created () {
329+
injected = [this.foo]
330+
}
331+
}
332+
new Vue({
333+
mixins: [mixinA, mixinB],
334+
render (h) {
335+
return h(child)
336+
}
337+
}).$mount()
338+
339+
expect(injected).toEqual(['bar'])
340+
})
301341
})

0 commit comments

Comments
 (0)