@@ -250,6 +250,68 @@ describe('Options provide/inject', () => {
250
250
expect ( injected ) . toEqual ( [ 1 , false ] )
251
251
} )
252
252
253
+ it ( 'should merge from mixins properly (objects)' , ( ) => {
254
+ const mixinA = { inject : { foo : 'foo' } }
255
+ const mixinB = { inject : { bar : 'bar' } }
256
+ const child = {
257
+ mixins : [ mixinA , mixinB ] ,
258
+ template : `<span/>` ,
259
+ created ( ) {
260
+ injected = [ this . foo , this . bar ]
261
+ }
262
+ }
263
+ new Vue ( {
264
+ provide : { foo : 'foo' , bar : 'bar' , baz : 'baz' } ,
265
+ render ( h ) {
266
+ return h ( child )
267
+ }
268
+ } ) . $mount ( )
269
+
270
+ expect ( injected ) . toEqual ( [ 'foo' , 'bar' ] )
271
+ } )
272
+
273
+ it ( 'should merge from mixins properly (arrays)' , ( ) => {
274
+ const mixinA = { inject : [ 'foo' ] }
275
+ const mixinB = { inject : [ 'bar' ] }
276
+ const child = {
277
+ mixins : [ mixinA , mixinB ] ,
278
+ inject : [ 'baz' ] ,
279
+ template : `<span/>` ,
280
+ created ( ) {
281
+ injected = [ this . foo , this . bar , this . baz ]
282
+ }
283
+ }
284
+ new Vue ( {
285
+ provide : { foo : 'foo' , bar : 'bar' , baz : 'baz' } ,
286
+ render ( h ) {
287
+ return h ( child )
288
+ }
289
+ } ) . $mount ( )
290
+
291
+ expect ( injected ) . toEqual ( [ 'foo' , 'bar' , 'baz' ] )
292
+ } )
293
+
294
+ it ( 'should merge from mixins properly (mix of objects and arrays)' , ( ) => {
295
+ const mixinA = { inject : { foo : 'foo' } }
296
+ const mixinB = { inject : [ 'bar' ] }
297
+ const child = {
298
+ mixins : [ mixinA , mixinB ] ,
299
+ inject : { qux : 'baz' } ,
300
+ template : `<span/>` ,
301
+ created ( ) {
302
+ injected = [ this . foo , this . bar , this . qux ]
303
+ }
304
+ }
305
+ new Vue ( {
306
+ provide : { foo : 'foo' , bar : 'bar' , baz : 'baz' } ,
307
+ render ( h ) {
308
+ return h ( child )
309
+ }
310
+ } ) . $mount ( )
311
+
312
+ expect ( injected ) . toEqual ( [ 'foo' , 'bar' , 'baz' ] )
313
+ } )
314
+
253
315
it ( 'should warn when injections has been modified' , ( ) => {
254
316
const key = 'foo'
255
317
const vm = new Vue ( {
0 commit comments