@@ -37,6 +37,25 @@ describe('Store', () => {
3737 expect ( store . state . a ) . toBe ( 3 )
3838 } )
3939
40+ it ( 'asserts committed type' , ( ) => {
41+ const store = new Vuex . Store ( {
42+ state : {
43+ a : 1
44+ } ,
45+ mutations : {
46+ // Maybe registered with undefined type accidentally
47+ // if the user has typo in a constant type
48+ undefined ( state , n ) {
49+ state . a += n
50+ }
51+ }
52+ } )
53+ expect ( ( ) => {
54+ store . commit ( undefined , 2 )
55+ } ) . toThrowError ( / E x p e c t s s t r i n g a s t h e t y p e , b u t f o u n d u n d e f i n e d / )
56+ expect ( store . state . a ) . toBe ( 1 )
57+ } )
58+
4059 it ( 'dispatching actions, sync' , ( ) => {
4160 const store = new Vuex . Store ( {
4261 state : {
@@ -166,6 +185,30 @@ describe('Store', () => {
166185 } )
167186 } )
168187
188+ it ( 'asserts dispatched type' , ( ) => {
189+ const store = new Vuex . Store ( {
190+ state : {
191+ a : 1
192+ } ,
193+ mutations : {
194+ [ TEST ] ( state , n ) {
195+ state . a += n
196+ }
197+ } ,
198+ actions : {
199+ // Maybe registered with undefined type accidentally
200+ // if the user has typo in a constant type
201+ undefined ( { commit } , n ) {
202+ commit ( TEST , n )
203+ }
204+ }
205+ } )
206+ expect ( ( ) => {
207+ store . dispatch ( undefined , 2 )
208+ } ) . toThrowError ( / E x p e c t s s t r i n g a s t h e t y p e , b u t f o u n d u n d e f i n e d / )
209+ expect ( store . state . a ) . toBe ( 1 )
210+ } )
211+
169212 it ( 'getters' , ( ) => {
170213 const store = new Vuex . Store ( {
171214 state : {
0 commit comments