mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2024-11-10 19:56:54 +03:00
Add error on undefined action type
This commit is contained in:
parent
72cd8d0505
commit
4ceaf3d09a
|
@ -16,6 +16,12 @@ export const ActionTypes = {
|
|||
*/
|
||||
export const ActionCreators = {
|
||||
performAction(action) {
|
||||
if (typeof action.type === 'undefined') {
|
||||
throw new Error(
|
||||
'Actions may not have an undefined "type" property. ' +
|
||||
'Have you misspelled a constant?'
|
||||
);
|
||||
}
|
||||
return { type: ActionTypes.PERFORM_ACTION, action, timestamp: Date.now() };
|
||||
},
|
||||
|
||||
|
|
|
@ -176,6 +176,14 @@ describe('instrument', () => {
|
|||
spy.restore();
|
||||
});
|
||||
|
||||
it('should catch invalid action type', () => {
|
||||
expect(() => {
|
||||
store.dispatch({ type: undefined });
|
||||
}).toThrow(
|
||||
/Actions may not have an undefined/
|
||||
);
|
||||
});
|
||||
|
||||
it('should return the last non-undefined state from getState', () => {
|
||||
let storeWithBug = instrument()(createStore)(counterWithBug);
|
||||
storeWithBug.dispatch({ type: 'INCREMENT' });
|
||||
|
|
Loading…
Reference in New Issue
Block a user