@@ -94,6 +94,22 @@ describe('Helpers', () => {
94
94
expect ( vm . value . b ) . toBeUndefined ( )
95
95
} )
96
96
97
+ it ( 'mapState (with undefined states)' , ( ) => {
98
+ const store = new Vuex . Store ( {
99
+ modules : {
100
+ foo : {
101
+ namespaced : true ,
102
+ state : { a : 1 }
103
+ }
104
+ }
105
+ } )
106
+ const vm = new Vue ( {
107
+ store,
108
+ computed : mapState ( 'foo' )
109
+ } )
110
+ expect ( vm . a ) . toBeUndefined ( )
111
+ } )
112
+
97
113
it ( 'mapMutations (array)' , ( ) => {
98
114
const store = new Vuex . Store ( {
99
115
state : { count : 0 } ,
@@ -206,6 +222,27 @@ describe('Helpers', () => {
206
222
expect ( store . state . foo . count ) . toBe ( 43 )
207
223
} )
208
224
225
+ it ( 'mapMutations (with undefined mutations)' , ( ) => {
226
+ const store = new Vuex . Store ( {
227
+ modules : {
228
+ foo : {
229
+ namespaced : true ,
230
+ state : { count : 0 } ,
231
+ mutations : {
232
+ inc : state => state . count ++ ,
233
+ dec : state => state . count --
234
+ }
235
+ }
236
+ }
237
+ } )
238
+ const vm = new Vue ( {
239
+ store,
240
+ methods : mapMutations ( 'foo' )
241
+ } )
242
+ expect ( vm . inc ) . toBeUndefined ( )
243
+ expect ( vm . dec ) . toBeUndefined ( )
244
+ } )
245
+
209
246
it ( 'mapGetters (array)' , ( ) => {
210
247
const store = new Vuex . Store ( {
211
248
state : { count : 0 } ,
@@ -351,6 +388,31 @@ describe('Helpers', () => {
351
388
expect ( vm . count ) . toBe ( 9 )
352
389
} )
353
390
391
+ it ( 'mapGetters (with undefined getters)' , ( ) => {
392
+ const store = new Vuex . Store ( {
393
+ modules : {
394
+ foo : {
395
+ namespaced : true ,
396
+ state : { count : 0 } ,
397
+ mutations : {
398
+ inc : state => state . count ++ ,
399
+ dec : state => state . count --
400
+ } ,
401
+ getters : {
402
+ hasAny : ( { count } ) => count > 0 ,
403
+ negative : ( { count } ) => count < 0
404
+ }
405
+ }
406
+ }
407
+ } )
408
+ const vm = new Vue ( {
409
+ store,
410
+ computed : mapGetters ( 'foo' )
411
+ } )
412
+ expect ( vm . a ) . toBeUndefined ( )
413
+ expect ( vm . b ) . toBeUndefined ( )
414
+ } )
415
+
354
416
it ( 'mapActions (array)' , ( ) => {
355
417
const a = jasmine . createSpy ( )
356
418
const b = jasmine . createSpy ( )
@@ -461,6 +523,26 @@ describe('Helpers', () => {
461
523
expect ( a . calls . argsFor ( 0 ) [ 1 ] ) . toBe ( 'foobar' )
462
524
} )
463
525
526
+ it ( 'mapActions (with undefined actions)' , ( ) => {
527
+ const a = jasmine . createSpy ( )
528
+ const store = new Vuex . Store ( {
529
+ modules : {
530
+ foo : {
531
+ namespaced : true ,
532
+ actions : {
533
+ a
534
+ }
535
+ }
536
+ }
537
+ } )
538
+ const vm = new Vue ( {
539
+ store,
540
+ methods : mapActions ( 'foo/' )
541
+ } )
542
+ expect ( vm . a ) . toBeUndefined ( )
543
+ expect ( a ) . not . toHaveBeenCalled ( )
544
+ } )
545
+
464
546
it ( 'createNamespacedHelpers' , ( ) => {
465
547
const actionA = jasmine . createSpy ( )
466
548
const actionB = jasmine . createSpy ( )
0 commit comments