@@ -184,11 +184,21 @@ describe('Vuex', () => {
184184 [ TEST ] ( state , n ) {
185185 state . a += n
186186 }
187+ } ,
188+ actions : {
189+ check ( { getters } , value ) {
190+ // check for exposing getters into actions
191+ expect ( getters . hasAny ) . to . equal ( value )
192+ }
187193 }
188194 } )
189195 expect ( store . getters . hasAny ) . to . equal ( false )
196+ store . dispatch ( 'check' , false )
197+
190198 store . commit ( TEST , 1 )
199+
191200 expect ( store . getters . hasAny ) . to . equal ( true )
201+ store . dispatch ( 'check' , true )
192202 } )
193203
194204 it ( 'dynamic module registration' , ( ) => {
@@ -799,23 +809,43 @@ describe('Vuex', () => {
799809 inc : state => state . count ++
800810 } ,
801811 getters : {
802- hasAny : state => state . count > 0
812+ count : state => state . count
813+ } ,
814+ actions : {
815+ check ( { getters } , value ) {
816+ expect ( getters . count ) . to . equal ( value )
817+ }
803818 }
804819 } )
805820
806821 const spy = sinon . spy ( )
807822 const vm = new Vue ( {
808823 computed : {
809- a : ( ) => store . getters . hasAny
824+ a : ( ) => store . getters . count
810825 } ,
811826 watch : {
812827 a : spy
813828 }
814829 } )
815830
816- expect ( vm . a ) . to . equal ( false )
831+ expect ( vm . a ) . to . equal ( 0 )
832+ store . dispatch ( 'check' , 0 )
833+
817834 store . commit ( 'inc' )
818- expect ( vm . a ) . to . equal ( true )
835+
836+ expect ( vm . a ) . to . equal ( 1 )
837+ store . dispatch ( 'check' , 1 )
838+
839+ // update getters
840+ store . hotUpdate ( {
841+ getters : {
842+ count : state => state . count * 10
843+ }
844+ } )
845+
846+ expect ( vm . a ) . to . equal ( 10 )
847+ store . dispatch ( 'check' , 10 )
848+
819849 Vue . nextTick ( ( ) => {
820850 expect ( spy ) . to . have . been . called
821851 done ( )
0 commit comments