@@ -94,6 +94,22 @@ describe('Helpers', () => {
9494 expect ( vm . value . b ) . toBeUndefined ( )
9595 } )
9696
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+
97113 it ( 'mapMutations (array)' , ( ) => {
98114 const store = new Vuex . Store ( {
99115 state : { count : 0 } ,
@@ -206,6 +222,27 @@ describe('Helpers', () => {
206222 expect ( store . state . foo . count ) . toBe ( 43 )
207223 } )
208224
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+
209246 it ( 'mapGetters (array)' , ( ) => {
210247 const store = new Vuex . Store ( {
211248 state : { count : 0 } ,
@@ -351,6 +388,31 @@ describe('Helpers', () => {
351388 expect ( vm . count ) . toBe ( 9 )
352389 } )
353390
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+
354416 it ( 'mapActions (array)' , ( ) => {
355417 const a = jasmine . createSpy ( )
356418 const b = jasmine . createSpy ( )
@@ -461,6 +523,26 @@ describe('Helpers', () => {
461523 expect ( a . calls . argsFor ( 0 ) [ 1 ] ) . toBe ( 'foobar' )
462524 } )
463525
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+
464546 it ( 'createNamespacedHelpers' , ( ) => {
465547 const actionA = jasmine . createSpy ( )
466548 const actionB = jasmine . createSpy ( )
0 commit comments