Commit 65fb77ce by Hugo Häggmark

Fixed a small bug and added case sensitivity

parent 0ddaa95d
...@@ -46,7 +46,7 @@ describe('actionCreatorFactory', () => { ...@@ -46,7 +46,7 @@ describe('actionCreatorFactory', () => {
setup(payload); setup(payload);
expect(() => { expect(() => {
actionCreatorFactory<Dummy>('dummy').create(); actionCreatorFactory<Dummy>('DuMmY').create();
}).toThrow(); }).toThrow();
}); });
}); });
......
...@@ -21,7 +21,7 @@ export const actionCreatorFactory = <Payload>(type: string): ActionCreatorFactor ...@@ -21,7 +21,7 @@ export const actionCreatorFactory = <Payload>(type: string): ActionCreatorFactor
return Object.assign((payload: Payload): GrafanaAction<Payload> => ({ type, payload }), { type }); return Object.assign((payload: Payload): GrafanaAction<Payload> => ({ type, payload }), { type });
}; };
if (allActionCreators.some(t => type === type)) { if (allActionCreators.some(t => (t && type ? t.toLocaleUpperCase() === type.toLocaleUpperCase() : false))) {
throw new Error(`There is already an actionCreator defined with the type ${type}`); throw new Error(`There is already an actionCreator defined with the type ${type}`);
} }
...@@ -30,4 +30,5 @@ export const actionCreatorFactory = <Payload>(type: string): ActionCreatorFactor ...@@ -30,4 +30,5 @@ export const actionCreatorFactory = <Payload>(type: string): ActionCreatorFactor
return { create }; return { create };
}; };
// Should only be used by tests
export const resetAllActionCreatorTypes = () => (allActionCreators.length = 0); export const resetAllActionCreatorTypes = () => (allActionCreators.length = 0);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment