From 65fb77ce73cc9bcab8d63d899dbbdf9c4f749fea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=A4ggmark?= Date: Wed, 30 Jan 2019 11:28:23 +0100 Subject: [PATCH] Fixed a small bug and added case sensitivity --- public/app/core/redux/actionCreatorFactory.test.ts | 2 +- public/app/core/redux/actionCreatorFactory.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/public/app/core/redux/actionCreatorFactory.test.ts b/public/app/core/redux/actionCreatorFactory.test.ts index 18ba6915368..96464354411 100644 --- a/public/app/core/redux/actionCreatorFactory.test.ts +++ b/public/app/core/redux/actionCreatorFactory.test.ts @@ -46,7 +46,7 @@ describe('actionCreatorFactory', () => { setup(payload); expect(() => { - actionCreatorFactory('dummy').create(); + actionCreatorFactory('DuMmY').create(); }).toThrow(); }); }); diff --git a/public/app/core/redux/actionCreatorFactory.ts b/public/app/core/redux/actionCreatorFactory.ts index 936440f735a..d6e33160d5f 100644 --- a/public/app/core/redux/actionCreatorFactory.ts +++ b/public/app/core/redux/actionCreatorFactory.ts @@ -21,7 +21,7 @@ export const actionCreatorFactory = (type: string): ActionCreatorFactor return Object.assign((payload: Payload): GrafanaAction => ({ 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}`); } @@ -30,4 +30,5 @@ export const actionCreatorFactory = (type: string): ActionCreatorFactor return { create }; }; +// Should only be used by tests export const resetAllActionCreatorTypes = () => (allActionCreators.length = 0);