File tree Expand file tree Collapse file tree 3 files changed +10
-18
lines changed
Expand file tree Collapse file tree 3 files changed +10
-18
lines changed Original file line number Diff line number Diff 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+ */
3336const 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 } ;
Original file line number Diff line number Diff 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 ) ;
Original file line number Diff line number Diff line change @@ -7,21 +7,10 @@ jest.mock('@guardian/libs', () => ({
77
88// Mock window.guardian
99const 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
2615describe ( 'BetaABTests' , ( ) => {
2716 let betaABTests : BetaABTests ;
You can’t perform that action at this time.
0 commit comments