@@ -3,7 +3,7 @@ import chai, { expect } from 'chai'
33import sinonChai from 'sinon-chai'
44import sinon from 'sinon'
55import Vue from 'vue'
6- import Vuex , { mapGetters , mapActions } from '../../build/dev-entry'
6+ import Vuex , { mapState , mapMutations , mapGetters , mapActions } from '../../build/dev-entry'
77
88Vue . use ( Vuex )
99chai . use ( sinonChai )
@@ -225,6 +225,62 @@ describe('Vuex', () => {
225225 expect ( child . $store ) . to . equal ( store )
226226 } )
227227
228+ it ( 'helper: mapState' , ( ) => {
229+ const store = new Vuex . Store ( {
230+ state : {
231+ a : 1
232+ }
233+ } )
234+ const vm = new Vue ( {
235+ store,
236+ computed : mapState ( {
237+ a : state => state . a + 1
238+ } )
239+ } )
240+ expect ( vm . a ) . to . equal ( 2 )
241+ store . state . a ++
242+ expect ( vm . a ) . to . equal ( 3 )
243+ } )
244+
245+ it ( 'helper: mapMutations (array)' , ( ) => {
246+ const store = new Vuex . Store ( {
247+ state : { count : 0 } ,
248+ mutations : {
249+ inc : state => state . count ++ ,
250+ dec : state => state . count --
251+ }
252+ } )
253+ const vm = new Vue ( {
254+ store,
255+ methods : mapMutations ( [ 'inc' , 'dec' ] )
256+ } )
257+ vm . inc ( )
258+ expect ( store . state . count ) . to . equal ( 1 )
259+ vm . dec ( )
260+ expect ( store . state . count ) . to . equal ( 0 )
261+ } )
262+
263+ it ( 'helper: mapMutations (object)' , ( ) => {
264+ const store = new Vuex . Store ( {
265+ state : { count : 0 } ,
266+ mutations : {
267+ inc : state => state . count ++ ,
268+ dec : state => state . count --
269+ }
270+ } )
271+ const vm = new Vue ( {
272+ store,
273+ methods : mapMutations ( {
274+ plus : 'inc' ,
275+ minus : 'dec'
276+ } )
277+ } )
278+ vm . plus ( )
279+ expect ( store . state . count ) . to . equal ( 1 )
280+ vm . minus ( )
281+ expect ( store . state . count ) . to . equal ( 0 )
282+ } )
283+
228284 it ( 'helper: mapGetters (array)' , ( ) => {
229285 const store = new Vuex . Store ( {
230286 state : { count : 0 } ,
0 commit comments