@featurevisor/core 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/LICENSE +21 -0
- package/README.md +15 -0
- package/lib/builder.d.ts +12 -0
- package/lib/builder.js +245 -0
- package/lib/builder.js.map +1 -0
- package/lib/config.d.ts +25 -0
- package/lib/config.js +41 -0
- package/lib/config.js.map +1 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +22 -0
- package/lib/index.js.map +1 -0
- package/lib/init.d.ts +6 -0
- package/lib/init.js +38 -0
- package/lib/init.js.map +1 -0
- package/lib/linter.d.ts +9 -0
- package/lib/linter.js +334 -0
- package/lib/linter.js.map +1 -0
- package/lib/tester.d.ts +26 -0
- package/lib/tester.js +98 -0
- package/lib/tester.js.map +1 -0
- package/lib/traffic.d.ts +2 -0
- package/lib/traffic.js +105 -0
- package/lib/traffic.js.map +1 -0
- package/lib/traffic.spec.d.ts +1 -0
- package/lib/traffic.spec.js +636 -0
- package/lib/traffic.spec.js.map +1 -0
- package/lib/utils.d.ts +5 -0
- package/lib/utils.js +70 -0
- package/lib/utils.js.map +1 -0
- package/package.json +57 -0
- package/src/builder.ts +359 -0
- package/src/config.ts +62 -0
- package/src/index.ts +5 -0
- package/src/init.ts +44 -0
- package/src/linter.ts +328 -0
- package/src/tester.ts +163 -0
- package/src/traffic.spec.ts +681 -0
- package/src/traffic.ts +136 -0
- package/src/utils.ts +83 -0
- package/tsconfig.cjs.json +7 -0
|
@@ -0,0 +1,681 @@
|
|
|
1
|
+
import { DatafileContent, GroupSegment, ParsedFeature } from "@featurevisor/types";
|
|
2
|
+
import { getNewTraffic } from "./traffic";
|
|
3
|
+
|
|
4
|
+
describe("core: Traffic", function () {
|
|
5
|
+
it("should be a function", function () {
|
|
6
|
+
expect(typeof getNewTraffic).toEqual("function");
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("should allocate traffic for 100-0 weight on two variations", function () {
|
|
10
|
+
const result = getNewTraffic(
|
|
11
|
+
// parsed variations from YAML
|
|
12
|
+
[
|
|
13
|
+
{
|
|
14
|
+
type: "string",
|
|
15
|
+
value: "on",
|
|
16
|
+
weight: 100,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
type: "string",
|
|
20
|
+
value: "off",
|
|
21
|
+
weight: 0,
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
|
|
25
|
+
// parsed rollouts from YAML
|
|
26
|
+
[
|
|
27
|
+
{
|
|
28
|
+
key: "1",
|
|
29
|
+
segments: "*",
|
|
30
|
+
percentage: 80,
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
|
|
34
|
+
// existing feature from previous release
|
|
35
|
+
undefined,
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
expect(result).toEqual([
|
|
39
|
+
{
|
|
40
|
+
key: "1",
|
|
41
|
+
segments: "*",
|
|
42
|
+
percentage: 80000,
|
|
43
|
+
allocation: [
|
|
44
|
+
{
|
|
45
|
+
variation: "on",
|
|
46
|
+
percentage: 80000,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
variation: "off",
|
|
50
|
+
percentage: 0,
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
]);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("should allocate traffic for 50-50 weight on two variations", function () {
|
|
58
|
+
const result = getNewTraffic(
|
|
59
|
+
// parsed variations from YAML
|
|
60
|
+
[
|
|
61
|
+
{
|
|
62
|
+
type: "string",
|
|
63
|
+
value: "on",
|
|
64
|
+
weight: 50,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
type: "string",
|
|
68
|
+
value: "off",
|
|
69
|
+
weight: 50,
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
|
|
73
|
+
// parsed rollouts from YAML
|
|
74
|
+
[
|
|
75
|
+
{
|
|
76
|
+
key: "1",
|
|
77
|
+
segments: "*",
|
|
78
|
+
percentage: 80,
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
|
|
82
|
+
// existing feature from previous release
|
|
83
|
+
undefined,
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
expect(result).toEqual([
|
|
87
|
+
{
|
|
88
|
+
key: "1",
|
|
89
|
+
segments: "*",
|
|
90
|
+
percentage: 80000,
|
|
91
|
+
allocation: [
|
|
92
|
+
{
|
|
93
|
+
variation: "on",
|
|
94
|
+
percentage: 40000,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
variation: "off",
|
|
98
|
+
percentage: 40000,
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
]);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it("should allocate traffic for weight with two decimal places among three variations", function () {
|
|
106
|
+
const result = getNewTraffic(
|
|
107
|
+
// parsed variations from YAML
|
|
108
|
+
[
|
|
109
|
+
{
|
|
110
|
+
type: "string",
|
|
111
|
+
value: "yes",
|
|
112
|
+
weight: 33.33,
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
type: "string",
|
|
116
|
+
value: "no",
|
|
117
|
+
weight: 33.33,
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
type: "string",
|
|
121
|
+
value: "maybe",
|
|
122
|
+
weight: 33.34,
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
|
|
126
|
+
// parsed rollouts from YAML
|
|
127
|
+
[
|
|
128
|
+
{
|
|
129
|
+
key: "1",
|
|
130
|
+
segments: "*",
|
|
131
|
+
percentage: 100,
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
|
|
135
|
+
// existing feature from previous release
|
|
136
|
+
undefined,
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
expect(result).toEqual([
|
|
140
|
+
{
|
|
141
|
+
key: "1",
|
|
142
|
+
segments: "*",
|
|
143
|
+
percentage: 100000,
|
|
144
|
+
allocation: [
|
|
145
|
+
{
|
|
146
|
+
variation: "yes",
|
|
147
|
+
percentage: 33330,
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
variation: "no",
|
|
151
|
+
percentage: 33330,
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
variation: "maybe",
|
|
155
|
+
percentage: 33340,
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
},
|
|
159
|
+
]);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it("should allocate against previous known allocation, increasing from 80% to 90%, with same variations and weight", function () {
|
|
163
|
+
const result = getNewTraffic(
|
|
164
|
+
// parsed variations from YAML
|
|
165
|
+
[
|
|
166
|
+
{
|
|
167
|
+
type: "string",
|
|
168
|
+
value: "on",
|
|
169
|
+
weight: 50,
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
type: "string",
|
|
173
|
+
value: "off",
|
|
174
|
+
weight: 50,
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
|
|
178
|
+
// parsed rollouts from YAML
|
|
179
|
+
[
|
|
180
|
+
{
|
|
181
|
+
key: "1",
|
|
182
|
+
segments: "*",
|
|
183
|
+
percentage: 90,
|
|
184
|
+
},
|
|
185
|
+
],
|
|
186
|
+
|
|
187
|
+
// existing feature from previous release
|
|
188
|
+
{
|
|
189
|
+
variations: [
|
|
190
|
+
{
|
|
191
|
+
value: "on",
|
|
192
|
+
weight: 50,
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
value: "off",
|
|
196
|
+
weight: 50,
|
|
197
|
+
},
|
|
198
|
+
],
|
|
199
|
+
traffic: [
|
|
200
|
+
{
|
|
201
|
+
key: "1",
|
|
202
|
+
percentage: 80000,
|
|
203
|
+
allocation: [
|
|
204
|
+
{
|
|
205
|
+
variation: "on",
|
|
206
|
+
percentage: 40000,
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
variation: "off",
|
|
210
|
+
percentage: 40000,
|
|
211
|
+
},
|
|
212
|
+
],
|
|
213
|
+
},
|
|
214
|
+
],
|
|
215
|
+
},
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
expect(result).toEqual([
|
|
219
|
+
{
|
|
220
|
+
key: "1",
|
|
221
|
+
segments: "*",
|
|
222
|
+
percentage: 90000,
|
|
223
|
+
allocation: [
|
|
224
|
+
// existing
|
|
225
|
+
{
|
|
226
|
+
variation: "on",
|
|
227
|
+
percentage: 40000,
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
variation: "off",
|
|
231
|
+
percentage: 40000,
|
|
232
|
+
},
|
|
233
|
+
|
|
234
|
+
// new
|
|
235
|
+
{
|
|
236
|
+
variation: "on",
|
|
237
|
+
percentage: 5000,
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
variation: "off",
|
|
241
|
+
percentage: 5000,
|
|
242
|
+
},
|
|
243
|
+
],
|
|
244
|
+
},
|
|
245
|
+
]);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it("should allocate against previous known allocation, decreasing from 80% to 70%, with same variations and weight", function () {
|
|
249
|
+
const result = getNewTraffic(
|
|
250
|
+
// parsed variations from YAML
|
|
251
|
+
[
|
|
252
|
+
{
|
|
253
|
+
type: "string",
|
|
254
|
+
value: "on",
|
|
255
|
+
weight: 50,
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
type: "string",
|
|
259
|
+
value: "off",
|
|
260
|
+
weight: 50,
|
|
261
|
+
},
|
|
262
|
+
],
|
|
263
|
+
|
|
264
|
+
// parsed rollouts from YAML
|
|
265
|
+
[
|
|
266
|
+
{
|
|
267
|
+
key: "1",
|
|
268
|
+
segments: "*",
|
|
269
|
+
percentage: 70,
|
|
270
|
+
},
|
|
271
|
+
],
|
|
272
|
+
|
|
273
|
+
// existing feature from previous release
|
|
274
|
+
{
|
|
275
|
+
variations: [
|
|
276
|
+
{
|
|
277
|
+
value: "on",
|
|
278
|
+
weight: 50,
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
value: "off",
|
|
282
|
+
weight: 50,
|
|
283
|
+
},
|
|
284
|
+
],
|
|
285
|
+
traffic: [
|
|
286
|
+
{
|
|
287
|
+
key: "1",
|
|
288
|
+
percentage: 80000,
|
|
289
|
+
allocation: [
|
|
290
|
+
{
|
|
291
|
+
variation: "on",
|
|
292
|
+
percentage: 40000,
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
variation: "off",
|
|
296
|
+
percentage: 40000,
|
|
297
|
+
},
|
|
298
|
+
],
|
|
299
|
+
},
|
|
300
|
+
],
|
|
301
|
+
},
|
|
302
|
+
);
|
|
303
|
+
|
|
304
|
+
expect(result).toEqual([
|
|
305
|
+
{
|
|
306
|
+
key: "1",
|
|
307
|
+
segments: "*",
|
|
308
|
+
percentage: 70000,
|
|
309
|
+
allocation: [
|
|
310
|
+
{
|
|
311
|
+
variation: "on",
|
|
312
|
+
percentage: 35000,
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
variation: "off",
|
|
316
|
+
percentage: 35000,
|
|
317
|
+
},
|
|
318
|
+
],
|
|
319
|
+
},
|
|
320
|
+
]);
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
it("should allocate against previous known allocation, increasing from 80% to 90%, with new added variation", function () {
|
|
324
|
+
const result = getNewTraffic(
|
|
325
|
+
// parsed variations from YAML
|
|
326
|
+
[
|
|
327
|
+
{
|
|
328
|
+
type: "string",
|
|
329
|
+
value: "a",
|
|
330
|
+
weight: 33.33,
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
type: "string",
|
|
334
|
+
value: "b",
|
|
335
|
+
weight: 33.33,
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
type: "string",
|
|
339
|
+
value: "c",
|
|
340
|
+
weight: 33.34,
|
|
341
|
+
},
|
|
342
|
+
],
|
|
343
|
+
|
|
344
|
+
// parsed rollouts from YAML
|
|
345
|
+
[
|
|
346
|
+
{
|
|
347
|
+
key: "1",
|
|
348
|
+
segments: "*",
|
|
349
|
+
percentage: 90,
|
|
350
|
+
},
|
|
351
|
+
],
|
|
352
|
+
|
|
353
|
+
// existing feature from previous release
|
|
354
|
+
{
|
|
355
|
+
variations: [
|
|
356
|
+
{
|
|
357
|
+
value: "a",
|
|
358
|
+
weight: 50,
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
value: "b",
|
|
362
|
+
weight: 50,
|
|
363
|
+
},
|
|
364
|
+
],
|
|
365
|
+
traffic: [
|
|
366
|
+
{
|
|
367
|
+
key: "1",
|
|
368
|
+
percentage: 80000,
|
|
369
|
+
allocation: [
|
|
370
|
+
{
|
|
371
|
+
variation: "a",
|
|
372
|
+
percentage: 40000,
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
variation: "b",
|
|
376
|
+
percentage: 40000,
|
|
377
|
+
},
|
|
378
|
+
],
|
|
379
|
+
},
|
|
380
|
+
],
|
|
381
|
+
},
|
|
382
|
+
);
|
|
383
|
+
|
|
384
|
+
expect(result).toEqual([
|
|
385
|
+
{
|
|
386
|
+
key: "1",
|
|
387
|
+
segments: "*",
|
|
388
|
+
percentage: 90000,
|
|
389
|
+
allocation: [
|
|
390
|
+
{
|
|
391
|
+
variation: "a",
|
|
392
|
+
percentage: 29997,
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
variation: "b",
|
|
396
|
+
percentage: 29997,
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
variation: "c",
|
|
400
|
+
percentage: 30006,
|
|
401
|
+
},
|
|
402
|
+
],
|
|
403
|
+
},
|
|
404
|
+
]);
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
it("should allocate against previous known allocation, increasing from 80% to 100%, with new added variation, totalling 4 variations", function () {
|
|
408
|
+
const result = getNewTraffic(
|
|
409
|
+
// parsed variations from YAML
|
|
410
|
+
[
|
|
411
|
+
{
|
|
412
|
+
type: "string",
|
|
413
|
+
value: "a",
|
|
414
|
+
weight: 25,
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
type: "string",
|
|
418
|
+
value: "b",
|
|
419
|
+
weight: 25,
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
type: "string",
|
|
423
|
+
value: "c",
|
|
424
|
+
weight: 25,
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
type: "string",
|
|
428
|
+
value: "d",
|
|
429
|
+
weight: 25,
|
|
430
|
+
},
|
|
431
|
+
],
|
|
432
|
+
|
|
433
|
+
// parsed rollouts from YAML
|
|
434
|
+
[
|
|
435
|
+
{
|
|
436
|
+
key: "1",
|
|
437
|
+
segments: "*",
|
|
438
|
+
percentage: 100,
|
|
439
|
+
},
|
|
440
|
+
],
|
|
441
|
+
|
|
442
|
+
// existing feature from previous release
|
|
443
|
+
{
|
|
444
|
+
variations: [
|
|
445
|
+
{
|
|
446
|
+
value: "a",
|
|
447
|
+
weight: 50,
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
value: "b",
|
|
451
|
+
weight: 50,
|
|
452
|
+
},
|
|
453
|
+
],
|
|
454
|
+
traffic: [
|
|
455
|
+
{
|
|
456
|
+
key: "1",
|
|
457
|
+
percentage: 80000,
|
|
458
|
+
allocation: [
|
|
459
|
+
{
|
|
460
|
+
variation: "a",
|
|
461
|
+
percentage: 40000,
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
variation: "b",
|
|
465
|
+
percentage: 40000,
|
|
466
|
+
},
|
|
467
|
+
],
|
|
468
|
+
},
|
|
469
|
+
],
|
|
470
|
+
},
|
|
471
|
+
);
|
|
472
|
+
|
|
473
|
+
expect(result).toEqual([
|
|
474
|
+
{
|
|
475
|
+
key: "1",
|
|
476
|
+
segments: "*",
|
|
477
|
+
percentage: 100000,
|
|
478
|
+
allocation: [
|
|
479
|
+
{
|
|
480
|
+
variation: "a",
|
|
481
|
+
percentage: 25000,
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
variation: "b",
|
|
485
|
+
percentage: 25000,
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
variation: "c",
|
|
489
|
+
percentage: 25000,
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
variation: "d",
|
|
493
|
+
percentage: 25000,
|
|
494
|
+
},
|
|
495
|
+
],
|
|
496
|
+
},
|
|
497
|
+
]);
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
it("should allocate against previous known allocation, staying at same 100%, removing variations from 4 to 2", function () {
|
|
501
|
+
const result = getNewTraffic(
|
|
502
|
+
// parsed variations from YAML
|
|
503
|
+
[
|
|
504
|
+
{
|
|
505
|
+
type: "string",
|
|
506
|
+
value: "a",
|
|
507
|
+
weight: 50,
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
type: "string",
|
|
511
|
+
value: "b",
|
|
512
|
+
weight: 50,
|
|
513
|
+
},
|
|
514
|
+
],
|
|
515
|
+
|
|
516
|
+
// parsed rollouts from YAML
|
|
517
|
+
[
|
|
518
|
+
{
|
|
519
|
+
key: "1",
|
|
520
|
+
segments: "*",
|
|
521
|
+
percentage: 100,
|
|
522
|
+
},
|
|
523
|
+
],
|
|
524
|
+
|
|
525
|
+
// existing feature from previous release
|
|
526
|
+
{
|
|
527
|
+
variations: [
|
|
528
|
+
{
|
|
529
|
+
value: "a",
|
|
530
|
+
weight: 25,
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
value: "b",
|
|
534
|
+
weight: 25,
|
|
535
|
+
},
|
|
536
|
+
{
|
|
537
|
+
value: "c",
|
|
538
|
+
weight: 25,
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
value: "d",
|
|
542
|
+
weight: 25,
|
|
543
|
+
},
|
|
544
|
+
],
|
|
545
|
+
traffic: [
|
|
546
|
+
{
|
|
547
|
+
key: "1",
|
|
548
|
+
percentage: 100000,
|
|
549
|
+
allocation: [
|
|
550
|
+
{
|
|
551
|
+
variation: "a",
|
|
552
|
+
percentage: 25000,
|
|
553
|
+
},
|
|
554
|
+
{
|
|
555
|
+
variation: "b",
|
|
556
|
+
percentage: 25000,
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
variation: "c",
|
|
560
|
+
percentage: 25000,
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
variation: "d",
|
|
564
|
+
percentage: 25000,
|
|
565
|
+
},
|
|
566
|
+
],
|
|
567
|
+
},
|
|
568
|
+
],
|
|
569
|
+
},
|
|
570
|
+
);
|
|
571
|
+
|
|
572
|
+
expect(result).toEqual([
|
|
573
|
+
{
|
|
574
|
+
key: "1",
|
|
575
|
+
segments: "*",
|
|
576
|
+
percentage: 100000,
|
|
577
|
+
allocation: [
|
|
578
|
+
{
|
|
579
|
+
variation: "a",
|
|
580
|
+
percentage: 50000,
|
|
581
|
+
},
|
|
582
|
+
{
|
|
583
|
+
variation: "b",
|
|
584
|
+
percentage: 50000,
|
|
585
|
+
},
|
|
586
|
+
],
|
|
587
|
+
},
|
|
588
|
+
]);
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
it("should allocate against previous known allocation, decreasing from 100% to 80%, removing variations from 4 to 2", function () {
|
|
592
|
+
const result = getNewTraffic(
|
|
593
|
+
// parsed variations from YAML
|
|
594
|
+
[
|
|
595
|
+
{
|
|
596
|
+
type: "string",
|
|
597
|
+
value: "a",
|
|
598
|
+
weight: 50,
|
|
599
|
+
},
|
|
600
|
+
{
|
|
601
|
+
type: "string",
|
|
602
|
+
value: "b",
|
|
603
|
+
weight: 50,
|
|
604
|
+
},
|
|
605
|
+
],
|
|
606
|
+
|
|
607
|
+
// parsed rollouts from YAML
|
|
608
|
+
[
|
|
609
|
+
{
|
|
610
|
+
key: "1",
|
|
611
|
+
segments: "*",
|
|
612
|
+
percentage: 80,
|
|
613
|
+
},
|
|
614
|
+
],
|
|
615
|
+
|
|
616
|
+
// existing feature from previous release
|
|
617
|
+
{
|
|
618
|
+
variations: [
|
|
619
|
+
{
|
|
620
|
+
value: "a",
|
|
621
|
+
weight: 25,
|
|
622
|
+
},
|
|
623
|
+
{
|
|
624
|
+
value: "b",
|
|
625
|
+
weight: 25,
|
|
626
|
+
},
|
|
627
|
+
{
|
|
628
|
+
value: "c",
|
|
629
|
+
weight: 25,
|
|
630
|
+
},
|
|
631
|
+
{
|
|
632
|
+
value: "d",
|
|
633
|
+
weight: 25,
|
|
634
|
+
},
|
|
635
|
+
],
|
|
636
|
+
traffic: [
|
|
637
|
+
{
|
|
638
|
+
key: "1",
|
|
639
|
+
percentage: 100000,
|
|
640
|
+
allocation: [
|
|
641
|
+
{
|
|
642
|
+
variation: "a",
|
|
643
|
+
percentage: 25000,
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
variation: "b",
|
|
647
|
+
percentage: 25000,
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
variation: "c",
|
|
651
|
+
percentage: 25000,
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
variation: "d",
|
|
655
|
+
percentage: 25000,
|
|
656
|
+
},
|
|
657
|
+
],
|
|
658
|
+
},
|
|
659
|
+
],
|
|
660
|
+
},
|
|
661
|
+
);
|
|
662
|
+
|
|
663
|
+
expect(result).toEqual([
|
|
664
|
+
{
|
|
665
|
+
key: "1",
|
|
666
|
+
segments: "*",
|
|
667
|
+
percentage: 80000,
|
|
668
|
+
allocation: [
|
|
669
|
+
{
|
|
670
|
+
variation: "a",
|
|
671
|
+
percentage: 40000,
|
|
672
|
+
},
|
|
673
|
+
{
|
|
674
|
+
variation: "b",
|
|
675
|
+
percentage: 40000,
|
|
676
|
+
},
|
|
677
|
+
],
|
|
678
|
+
},
|
|
679
|
+
]);
|
|
680
|
+
});
|
|
681
|
+
});
|