File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ export function mapState (map) {
33 Object . keys ( map ) . forEach ( key => {
44 const fn = map [ key ]
55 res [ key ] = function mappedState ( ) {
6- return fn . call ( this , this . $store . state )
6+ return fn . call ( this , this . $store . state , this . $store . getters )
77 }
88 } )
99 return res
Original file line number Diff line number Diff line change @@ -229,17 +229,22 @@ describe('Vuex', () => {
229229 const store = new Vuex . Store ( {
230230 state : {
231231 a : 1
232+ } ,
233+ getters : {
234+ b : ( ) => 2
232235 }
233236 } )
234237 const vm = new Vue ( {
235238 store,
236239 computed : mapState ( {
237- a : state => state . a + 1
240+ a : ( state , getters ) => {
241+ return state . a + getters . b
242+ }
238243 } )
239244 } )
240- expect ( vm . a ) . to . equal ( 2 )
241- store . state . a ++
242245 expect ( vm . a ) . to . equal ( 3 )
246+ store . state . a ++
247+ expect ( vm . a ) . to . equal ( 4 )
243248 } )
244249
245250 it ( 'helper: mapMutations (array)' , ( ) => {
You can’t perform that action at this time.
0 commit comments