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) {
3
3
Object . keys ( map ) . forEach ( key => {
4
4
const fn = map [ key ]
5
5
res [ key ] = function mappedState ( ) {
6
- return fn . call ( this , this . $store . state )
6
+ return fn . call ( this , this . $store . state , this . $store . getters )
7
7
}
8
8
} )
9
9
return res
Original file line number Diff line number Diff line change @@ -229,17 +229,22 @@ describe('Vuex', () => {
229
229
const store = new Vuex . Store ( {
230
230
state : {
231
231
a : 1
232
+ } ,
233
+ getters : {
234
+ b : ( ) => 2
232
235
}
233
236
} )
234
237
const vm = new Vue ( {
235
238
store,
236
239
computed : mapState ( {
237
- a : state => state . a + 1
240
+ a : ( state , getters ) => {
241
+ return state . a + getters . b
242
+ }
238
243
} )
239
244
} )
240
- expect ( vm . a ) . to . equal ( 2 )
241
- store . state . a ++
242
245
expect ( vm . a ) . to . equal ( 3 )
246
+ store . state . a ++
247
+ expect ( vm . a ) . to . equal ( 4 )
243
248
} )
244
249
245
250
it ( 'helper: mapMutations (array)' , ( ) => {
You can’t perform that action at this time.
0 commit comments