@@ -31,6 +31,33 @@ import { newErrorDecision } from '../optimizely_decision';
31
31
import { ImpressionEvent } from '../event_processor/event_builder/user_event' ;
32
32
import { OptimizelyDecideOption } from '../shared_types' ;
33
33
34
+
35
+ const holdoutData = [
36
+ {
37
+ id : 'holdout_test_id' ,
38
+ key : 'holdout_test_key' ,
39
+ status : 'Running' ,
40
+ includeFlags : [ ] ,
41
+ excludeFlags : [ ] ,
42
+ audienceIds : [ ] ,
43
+ audienceConditions : [ ] ,
44
+ variations : [
45
+ {
46
+ id : 'holdout_variation_id' ,
47
+ key : 'holdout_variation_key' ,
48
+ variables : [ ] ,
49
+ featureEnabled : false ,
50
+ } ,
51
+ ] ,
52
+ trafficAllocation : [
53
+ {
54
+ entityId : 'holdout_variation_id' ,
55
+ endOfRange : 10000 ,
56
+ } ,
57
+ ] ,
58
+ } ,
59
+ ] ;
60
+
34
61
describe ( 'Optimizely' , ( ) => {
35
62
const eventDispatcher = {
36
63
dispatchEvent : ( ) => Promise . resolve ( { statusCode : 200 } ) ,
@@ -217,32 +244,7 @@ describe('Optimizely', () => {
217
244
it ( 'should dispatch impression event for holdout decision' , async ( ) => {
218
245
const datafile = getDecisionTestDatafile ( ) ;
219
246
220
- datafile . holdouts = [
221
- {
222
- id : 'holdout_test_id' ,
223
- key : 'holdout_test_key' ,
224
- status : 'Running' ,
225
- includeFlags : [ ] ,
226
- excludeFlags : [ ] ,
227
- audienceIds : [ ] ,
228
- audienceConditions : [ ] ,
229
- variations : [
230
- {
231
- id : 'holdout_variation_id' ,
232
- key : 'holdout_variation_key' ,
233
- variables : [ ] ,
234
- featureEnabled : false
235
- }
236
- ] ,
237
- trafficAllocation : [
238
- {
239
- entityId : 'holdout_variation_id' ,
240
- endOfRange : 10000
241
- }
242
- ]
243
- }
244
- ] ;
245
-
247
+ datafile . holdouts = holdoutData ;
246
248
const projectConfig = createProjectConfig ( datafile ) ;
247
249
248
250
const projectConfigManager = getMockProjectConfigManager ( {
@@ -307,31 +309,7 @@ describe('Optimizely', () => {
307
309
it ( 'should not dispatch impression event for holdout when DISABLE_DECISION_EVENT is used' , async ( ) => {
308
310
const datafile = getDecisionTestDatafile ( ) ;
309
311
310
- datafile . holdouts = [
311
- {
312
- id : 'holdout_test_id' ,
313
- key : 'holdout_test_key' ,
314
- status : 'Running' ,
315
- includeFlags : [ ] ,
316
- excludeFlags : [ ] ,
317
- audienceIds : [ ] ,
318
- audienceConditions : [ ] ,
319
- variations : [
320
- {
321
- id : 'holdout_variation_id' ,
322
- key : 'holdout_variation_key' ,
323
- variables : [ ] ,
324
- featureEnabled : false
325
- }
326
- ] ,
327
- trafficAllocation : [
328
- {
329
- entityId : 'holdout_variation_id' ,
330
- endOfRange : 10000
331
- }
332
- ]
333
- }
334
- ] ;
312
+ datafile . holdouts = holdoutData ;
335
313
336
314
const projectConfig = createProjectConfig ( datafile ) ;
337
315
@@ -387,31 +365,7 @@ describe('Optimizely', () => {
387
365
describe ( 'isFeatureEnabled' , ( ) => {
388
366
it ( 'should dispatch impression event for holdout decision' , async ( ) => {
389
367
const datafile = getDecisionTestDatafile ( ) ;
390
- datafile . holdouts = [
391
- {
392
- id : 'holdout_test_id' ,
393
- key : 'holdout_test_key' ,
394
- status : 'Running' ,
395
- includeFlags : [ ] ,
396
- excludeFlags : [ ] ,
397
- audienceIds : [ ] ,
398
- audienceConditions : [ ] ,
399
- variations : [
400
- {
401
- id : 'holdout_variation_id' ,
402
- key : 'holdout_variation_key' ,
403
- variables : [ ] ,
404
- featureEnabled : false
405
- }
406
- ] ,
407
- trafficAllocation : [
408
- {
409
- entityId : 'holdout_variation_id' ,
410
- endOfRange : 10000
411
- }
412
- ]
413
- }
414
- ] ;
368
+ datafile . holdouts = holdoutData ;
415
369
416
370
const projectConfig = createProjectConfig ( datafile ) ;
417
371
const projectConfigManager = getMockProjectConfigManager ( {
0 commit comments