This repository was archived by the owner on Jun 7, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +36
-1
lines changed Expand file tree Collapse file tree 3 files changed +36
-1
lines changed Original file line number Diff line number Diff line change 77
88# Build
99dist
10+
11+ # Editor artifacts
12+ .idea
Original file line number Diff line number Diff line change @@ -319,7 +319,7 @@ export default (experimentName) =>
319319 * The wrapped component
320320 */
321321 ( Component ) =>
322- ( ) => {
322+ ( props ) => {
323323 // Activate the experiment
324324 const isActive = activate ( experimentName )
325325
@@ -328,5 +328,6 @@ export default (experimentName) =>
328328 const variant = getVariant ( experimentName )
329329
330330 return < Component
331+ { ...props }
331332 optimizely = { { experiment, variant, isActive } } />
332333 }
Original file line number Diff line number Diff line change @@ -124,3 +124,34 @@ test('connect: activated and experiment', (t) => {
124124 } )
125125 t . is ( frame . props . optimizely . isActive , true )
126126} )
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