This repository was archived by the owner on Jun 7, 2021. It is now read-only.
File tree 3 files changed +36
-1
lines changed
3 files changed +36
-1
lines changed Original file line number Diff line number Diff line change 7
7
8
8
# Build
9
9
dist
10
+
11
+ # Editor artifacts
12
+ .idea
Original file line number Diff line number Diff line change @@ -319,7 +319,7 @@ export default (experimentName) =>
319
319
* The wrapped component
320
320
*/
321
321
( Component ) =>
322
- ( ) => {
322
+ ( props ) => {
323
323
// Activate the experiment
324
324
const isActive = activate ( experimentName )
325
325
@@ -328,5 +328,6 @@ export default (experimentName) =>
328
328
const variant = getVariant ( experimentName )
329
329
330
330
return < Component
331
+ { ...props }
331
332
optimizely = { { experiment, variant, isActive } } />
332
333
}
Original file line number Diff line number Diff line change @@ -124,3 +124,34 @@ test('connect: activated and experiment', (t) => {
124
124
} )
125
125
t . is ( frame . props . optimizely . isActive , true )
126
126
} )
127
+
128
+ test ( 'connect: props pass-through' , ( t ) => {
129
+ global . window = mockOptimizelyWindow ( {
130
+ allExperiments : {
131
+ 'A' : {
132
+ name : 'Experiment A' ,
133
+ enabled : true
134
+ }
135
+ } ,
136
+ variationMap : {
137
+ 'A' : {
138
+ 'name' : 'Variant A' ,
139
+ 'code' : 'JSCODE'
140
+ }
141
+ } ,
142
+ activeExperiments : [ 'A' ] ,
143
+ push : ( [ method , ...args ] ) => {
144
+ if ( method === 'activate' ) {
145
+ window . optimizely . activeExperiments = window . optimizely . activeExperiments || [ ]
146
+ window . optimizely . activeExperiments . push ( args [ 0 ] )
147
+ }
148
+ }
149
+ } )
150
+
151
+ const renderer = createRenderer (
152
+ connect ( 'Experiment A' ) ( TestComponent )
153
+ )
154
+ let frame = renderer . render ( { other : 'props' } )
155
+
156
+ t . is ( frame . props . other , 'props' )
157
+ } )
You can’t perform that action at this time.
0 commit comments