@@ -12,38 +12,42 @@ import { sdkBrowser } from './testUtils/sdkConfigs';
1212import { withSplitFactory } from '../withSplitFactory' ;
1313import { withSplitClient } from '../withSplitClient' ;
1414import { withSplitTreatments } from '../withSplitTreatments' ;
15- import { ISplitTreatmentsChildProps } from '../types' ;
1615import { getControlTreatmentsWithConfig } from '../constants' ;
1716
1817describe ( 'withSplitTreatments' , ( ) => {
1918
2019 it ( `passes Split props and outer props to the child.
21- In this test, the value of "props.treatments" is obteined by the function "getControlTreatmentsWithConfig",
22- and not "client.getTreatmentsWithConfig" since the client is not ready.` , ( done ) => {
20+ In this test, the value of "props.treatments" is obtained by the function "getControlTreatmentsWithConfig",
21+ and not "client.getTreatmentsWithConfig" since the client is not ready.` , ( ) => {
2322 const featureFlagNames = [ 'split1' , 'split2' ] ;
23+
2424 const Component = withSplitFactory ( sdkBrowser ) < { outerProp1 : string , outerProp2 : number } > (
2525 ( { outerProp1, outerProp2, factory } ) => {
2626 const SubComponent = withSplitClient ( 'user1' ) < { outerProp1 : string , outerProp2 : number } > (
2727 withSplitTreatments ( featureFlagNames ) (
28- ( props : ISplitTreatmentsChildProps & { outerProp1 : string , outerProp2 : number } ) => {
28+ ( props ) => {
2929 const clientMock = factory ! . client ( 'user1' ) ;
30- expect ( props . outerProp1 ) . toBe ( 'outerProp1' ) ;
31- expect ( props . outerProp2 ) . toBe ( 2 ) ;
3230 expect ( ( clientMock . getTreatmentsWithConfig as jest . Mock ) . mock . calls . length ) . toBe ( 0 ) ;
33- expect ( props . treatments ) . toEqual ( getControlTreatmentsWithConfig ( featureFlagNames ) ) ;
34- expect ( props . isReady ) . toBe ( false ) ;
35- expect ( props . isReadyFromCache ) . toBe ( false ) ;
36- expect ( props . hasTimedout ) . toBe ( false ) ;
37- expect ( props . isTimedout ) . toBe ( false ) ;
38- expect ( props . isDestroyed ) . toBe ( false ) ;
39- expect ( props . lastUpdate ) . toBe ( 0 ) ;
40- done ( ) ;
31+
32+ expect ( props ) . toStrictEqual ( {
33+ factory : factory , client : clientMock ,
34+ outerProp1 : 'outerProp1' , outerProp2 : 2 ,
35+ treatments : getControlTreatmentsWithConfig ( featureFlagNames ) ,
36+ isReady : false ,
37+ isReadyFromCache : false ,
38+ hasTimedout : false ,
39+ isTimedout : false ,
40+ isDestroyed : false ,
41+ lastUpdate : 0
42+ } ) ;
43+
4144 return null ;
4245 }
4346 )
4447 ) ;
4548 return < SubComponent outerProp1 = { outerProp1 } outerProp2 = { outerProp2 } /> ;
4649 } ) ;
50+
4751 render ( < Component outerProp1 = 'outerProp1' outerProp2 = { 2 } /> ) ;
4852 } ) ;
4953
0 commit comments