Skip to content

Commit 60972f0

Browse files
committed
update test
1 parent ef87cb7 commit 60972f0

File tree

3 files changed

+10
-18
lines changed

3 files changed

+10
-18
lines changed

dotcom-rendering/src/client/abTesting.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,17 @@ const getClientParticipations = (): ABParticipations => {
3030
return {};
3131
};
3232

33+
/**
34+
* Get all AB test participations, client and server side
35+
*/
3336
const getABTestParticipations = (): ABParticipations => {
3437
return {
3538
...getClientParticipations(),
3639
...window.guardian.config.serverSideABTests,
3740
};
3841
};
3942

40-
const initABTesting = (): void => {
43+
const initWindowABTesting = (): void => {
4144
const participations = getABTestParticipations();
4245

4346
window.guardian.modules.abTests = {
@@ -51,4 +54,4 @@ const initABTesting = (): void => {
5154
};
5255
};
5356

54-
export { initABTesting, getABTestParticipations };
57+
export { initWindowABTesting, getABTestParticipations };

dotcom-rendering/src/client/main.web.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void (async () => {
6161
'abTesting',
6262
() =>
6363
import(/* webpackMode: 'eager' */ './abTesting').then(
64-
({ initABTesting }) => initABTesting(),
64+
({ initWindowABTesting }) => initWindowABTesting(),
6565
),
6666
{ priority: 'critical' },
6767
);

dotcom-rendering/src/experiments/lib/beta-ab-tests.test.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,10 @@ jest.mock('@guardian/libs', () => ({
77

88
// Mock window.guardian
99
const mockGetParticipations = jest.fn();
10-
const mockWindow = {
11-
guardian: {
12-
modules: {
13-
abTests: {
14-
getParticipations: mockGetParticipations,
15-
},
16-
},
17-
},
18-
};
19-
20-
// Set up window mock
21-
Object.defineProperty(global, 'window', {
22-
value: mockWindow,
23-
writable: true,
24-
});
10+
11+
jest.mock('../../client/abTesting', () => ({
12+
getABTestParticipations: () => mockGetParticipations(),
13+
}));
2514

2615
describe('BetaABTests', () => {
2716
let betaABTests: BetaABTests;

0 commit comments

Comments
 (0)