@@ -110,6 +110,30 @@ describe('<OptimizelyFeature>', () => {
110
110
expect ( component . text ( ) ) . toBe ( 'true|bar' ) ;
111
111
} ) ;
112
112
113
+ it ( 'should pass the values for clientReady and didTimeout' , async ( ) => {
114
+ const component = mount (
115
+ < OptimizelyProvider optimizely = { optimizelyMock } timeout = { 200 } >
116
+ < OptimizelyFeature feature = "feature1" timeout = { 100 } >
117
+ { ( isEnabled , variables , clientReady , didTimeout ) =>
118
+ `${ isEnabled ? 'true' : 'false' } |${ variables . foo } |${ clientReady } |${ didTimeout } `
119
+ }
120
+ </ OptimizelyFeature >
121
+ </ OptimizelyProvider >
122
+ ) ;
123
+
124
+ // while it's waiting for onReady()
125
+ expect ( component . text ( ) ) . toBe ( '' ) ;
126
+ resolver . resolve ( { success : true } ) ;
127
+
128
+ await optimizelyMock . onReady ( ) ;
129
+
130
+ component . update ( ) ;
131
+
132
+ expect ( optimizelyMock . isFeatureEnabled ) . toHaveBeenCalledWith ( 'feature1' , undefined , undefined ) ;
133
+ expect ( optimizelyMock . getFeatureVariables ) . toHaveBeenCalledWith ( 'feature1' , undefined , undefined ) ;
134
+ expect ( component . text ( ) ) . toBe ( 'true|bar|true|false' ) ;
135
+ } ) ;
136
+
113
137
it ( 'should respect a locally passed timeout prop' , async ( ) => {
114
138
const component = mount (
115
139
< OptimizelyProvider optimizely = { optimizelyMock } timeout = { 200 } >
@@ -134,6 +158,28 @@ describe('<OptimizelyFeature>', () => {
134
158
expect ( component . text ( ) ) . toBe ( 'true|bar' ) ;
135
159
} ) ;
136
160
161
+ it ( 'should pass the override props through' , async ( ) => {
162
+ const component = mount (
163
+ < OptimizelyProvider optimizely = { optimizelyMock } timeout = { 200 } >
164
+ < OptimizelyFeature feature = "feature1" overrideUserId = "james123" overrideAttributes = { { betaUser : true } } >
165
+ { ( isEnabled , variables ) => `${ isEnabled ? 'true' : 'false' } |${ variables . foo } ` }
166
+ </ OptimizelyFeature >
167
+ </ OptimizelyProvider >
168
+ ) ;
169
+
170
+ // while it's waiting for onReady()
171
+ expect ( component . text ( ) ) . toBe ( '' ) ;
172
+ resolver . resolve ( { success : true } ) ;
173
+
174
+ await optimizelyMock . onReady ( ) ;
175
+
176
+ component . update ( ) ;
177
+
178
+ expect ( optimizelyMock . isFeatureEnabled ) . toHaveBeenCalledWith ( 'feature1' , 'james123' , { betaUser : true } ) ;
179
+ expect ( optimizelyMock . getFeatureVariables ) . toHaveBeenCalledWith ( 'feature1' , 'james123' , { betaUser : true } ) ;
180
+ expect ( component . text ( ) ) . toBe ( 'true|bar' ) ;
181
+ } ) ;
182
+
137
183
describe ( `when the "autoUpdate" prop is true` , ( ) => {
138
184
it ( 'should update when the OPTIMIZELY_CONFIG_UPDATE handler is called' , async ( ) => {
139
185
const component = mount (
0 commit comments