diff --git a/.storybook/preview.tsx b/.storybook/preview.tsx index 7716c48d..76c49f72 100644 --- a/.storybook/preview.tsx +++ b/.storybook/preview.tsx @@ -6,6 +6,7 @@ import { getSdkComponentMap } from '@pega/react-sdk-components/lib/bridge/helper import { theme } from '../src/theme'; import { decorator } from '../__mocks__/react_pconnect'; +import setPCoreMocks from '../__mocks__/pcoreMocks'; const isConstellation = process.env.STORYBOOK_CONSTELLATION; @@ -13,6 +14,8 @@ if (!isConstellation) { getSdkComponentMap(); } +setPCoreMocks(); + const decorators = [ (Story, context) => { return isConstellation ? ( diff --git a/__mocks__/pcoreMocks.tsx b/__mocks__/pcoreMocks.tsx new file mode 100644 index 00000000..5a1b8b32 --- /dev/null +++ b/__mocks__/pcoreMocks.tsx @@ -0,0 +1,27 @@ +export default function setPCoreMocks() { + if (!window.PCore) { + window.PCore = {} as any; + } + + window.PCore.getEnvironmentInfo = () => { + return { + getUseLocale: () => 'en-GB', + getLocale: () => 'en-GB', + getTimeZone: () => '' + } as any; + }; + + window.PCore.getLocaleUtils = () => { + return { + getLocaleValue: (value: any) => value + } as any; + }; + + window.PCore.getConstants = (): any => { + return { + CASE_INFO: { + INSTRUCTIONS: '' + } + }; + }; +}