Skip to content

Commit 9b1e93a

Browse files
author
Sharma
committed
Moved mocks to a separate file
1 parent e7dc199 commit 9b1e93a

File tree

2 files changed

+36
-27
lines changed

2 files changed

+36
-27
lines changed

.storybook/preview.tsx

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,21 @@ import { getSdkComponentMap } from '@pega/react-sdk-components/lib/bridge/helper
66
import { theme } from '../src/theme';
77

88
import { decorator } from '../__mocks__/react_pconnect';
9+
import setPCoreMocks from '../__mocks__/pcoreMocks';
910

1011
declare global {
1112
interface Window {
1213
PCore?: any;
1314
}
1415
}
1516

16-
const isConstellation = process.env.STORYBOOK_CONSTELLATION;
17-
18-
const setPCoreMocks = () => {
19-
if (!window.PCore) {
20-
window.PCore = {} as any;
17+
declare global {
18+
interface Window {
19+
PCore?: any;
2120
}
21+
}
2222

23-
window.PCore.getEnvironmentInfo = () => {
24-
return {
25-
getUseLocale: () => 'en-GB',
26-
getLocale: () => 'en-GB',
27-
getTimeZone: () => ''
28-
} as any;
29-
};
30-
31-
window.PCore.getLocaleUtils = () => {
32-
return {
33-
getLocaleValue: value => value
34-
} as any;
35-
};
36-
37-
window.PCore.getConstants = (): any => {
38-
return {
39-
CASE_INFO: {
40-
INSTRUCTIONS: ''
41-
}
42-
};
43-
};
44-
};
23+
const isConstellation = process.env.STORYBOOK_CONSTELLATION;
4524

4625
if (!isConstellation) {
4726
getSdkComponentMap();
@@ -103,3 +82,6 @@ const preview: Preview = {
10382
};
10483

10584
export default preview;
85+
function pcoreMocks() {
86+
throw new Error('Function not implemented.');
87+
}

__mocks__/pcoreMocks.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
export default function setPCoreMocks() {
2+
if (!window.PCore) {
3+
window.PCore = {} as any;
4+
}
5+
6+
window.PCore.getEnvironmentInfo = () => {
7+
return {
8+
getUseLocale: () => 'en-GB',
9+
getLocale: () => 'en-GB',
10+
getTimeZone: () => ''
11+
} as any;
12+
};
13+
14+
window.PCore.getLocaleUtils = () => {
15+
return {
16+
getLocaleValue: (value: any) => value
17+
} as any;
18+
};
19+
20+
window.PCore.getConstants = (): any => {
21+
return {
22+
CASE_INFO: {
23+
INSTRUCTIONS: ''
24+
}
25+
};
26+
};
27+
}

0 commit comments

Comments
 (0)