File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -251,6 +251,59 @@ describe('Helpers', () => {
251
251
expect ( vm . b ) . toBe ( true )
252
252
} )
253
253
254
+ it ( 'mapGetters (with namespace and nested module)' , ( ) => {
255
+ const store = new Vuex . Store ( {
256
+ modules : {
257
+ foo : {
258
+ namespaced : true ,
259
+ modules : {
260
+ bar : {
261
+ namespaced : true ,
262
+ state : { count : 0 } ,
263
+ mutations : {
264
+ inc : state => state . count ++ ,
265
+ dec : state => state . count --
266
+ } ,
267
+ getters : {
268
+ hasAny : ( { count } ) => count > 0 ,
269
+ negative : ( { count } ) => count < 0
270
+ }
271
+ } ,
272
+ cat : {
273
+ state : { count : 9 } ,
274
+ getters : {
275
+ count : ( { count } ) => count
276
+ }
277
+ }
278
+ }
279
+ }
280
+ }
281
+ } )
282
+ const vm = new Vue ( {
283
+ store,
284
+ computed : {
285
+ ...mapGetters ( 'foo/bar' , [
286
+ 'hasAny' ,
287
+ 'negative'
288
+ ] ) ,
289
+ ...mapGetters ( 'foo' , [
290
+ 'count'
291
+ ] )
292
+ }
293
+ } )
294
+ expect ( vm . hasAny ) . toBe ( false )
295
+ expect ( vm . negative ) . toBe ( false )
296
+ store . commit ( 'foo/bar/inc' )
297
+ expect ( vm . hasAny ) . toBe ( true )
298
+ expect ( vm . negative ) . toBe ( false )
299
+ store . commit ( 'foo/bar/dec' )
300
+ store . commit ( 'foo/bar/dec' )
301
+ expect ( vm . hasAny ) . toBe ( false )
302
+ expect ( vm . negative ) . toBe ( true )
303
+
304
+ expect ( vm . count ) . toBe ( 9 )
305
+ } )
306
+
254
307
it ( 'mapActions (array)' , ( ) => {
255
308
const a = jasmine . createSpy ( )
256
309
const b = jasmine . createSpy ( )
You can’t perform that action at this time.
0 commit comments