@@ -17,7 +17,11 @@ const ldClientInitialize = initialize as jest.Mock;
1717const clientSideID = 'deadbeef' ;
1818const defaultUser : LDUser = { key : 'abcdef' } ;
1919const options : LDOptions = { bootstrap : 'localStorage' } ;
20- const extraOptionsAddedBySdk : LDOptions = { wrapperName : 'react-client-sdk' , wrapperVersion : 'mock.version' } ;
20+ const extraOptionsAddedBySdk : LDOptions = {
21+ wrapperName : 'react-client-sdk' ,
22+ wrapperVersion : 'mock.version' ,
23+ sendEventsOnlyForVariation : true ,
24+ } ;
2125const expectedOptions : LDOptions = { ...options , ...extraOptionsAddedBySdk } ;
2226const flags = { 'test-flag' : false , 'another-test-flag' : true } ;
2327
@@ -89,4 +93,16 @@ describe('initLDClient', () => {
8993 expect ( mockLDClient . variation ) . toHaveBeenNthCalledWith ( 2 , 'lonelier-flag' , false ) ;
9094 expect ( flagsClient ) . toEqual ( { flags : { lonelyFlag : true , lonelierFlag : true } , ldClient : mockLDClient } ) ;
9195 } ) ;
96+
97+ test ( 'may explicity set sendEventsOnlyForVariation to false' , async ( ) => {
98+ const anonUser : LDUser = { anonymous : true } ;
99+ await initLDClient ( clientSideID , undefined , undefined , { ...options , sendEventsOnlyForVariation : false } ) ;
100+
101+ expect ( ldClientInitialize . mock . calls [ 0 ] ) . toEqual ( [
102+ clientSideID ,
103+ anonUser ,
104+ { ...expectedOptions , sendEventsOnlyForVariation : false } ,
105+ ] ) ;
106+ expect ( mockLDClient . variation ) . toHaveBeenCalledTimes ( 0 ) ;
107+ } ) ;
92108} ) ;
0 commit comments