forked from cypress-io/cypress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexperiments_spec.js
79 lines (73 loc) · 2.07 KB
/
experiments_spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
require('../spec_helper')
const { getExperiments, formatExperiments } = require(`../../lib/experiments.ts`)
describe('experiments', () => {
context('#formatExperiments', () => {
it('forms single string with all values', () => {
const exp = {
featureA: { value: true },
featureB: { value: false },
featureC: { value: true },
}
const result = formatExperiments(exp)
expect(result).to.equal('featureA=true,featureB=false,featureC=true')
})
})
context('#getExperiments', () => {
it('returns enabled experiments', () => {
const names = {
experimentalFoo: 'experiment foo',
experimentalBar: 'experiment bar',
experimentalBaz: 'experiment baz',
}
const summaries = {
experimentalFoo: 'feature foo summary',
experimentalBar: 'feature bar summary',
// let the system use the default summary for other features
}
const project = {
resolvedConfig: {
// nope, experiment is not enabled
experimentalFoo: {
value: true,
from: 'default',
},
// enabled
experimentalBar: {
value: true,
from: 'config',
},
// enabled
experimentalBaz: {
value: 5,
from: 'plugins',
},
},
}
const result = getExperiments(project, names, summaries)
const expected = {
experimentalFoo: {
value: true,
enabled: false,
key: 'experimentalFoo',
name: 'experiment foo',
summary: 'feature foo summary',
},
experimentalBar: {
value: true,
enabled: true,
key: 'experimentalBar',
name: 'experiment bar',
summary: 'feature bar summary',
},
experimentalBaz: {
value: 5,
enabled: true,
key: 'experimentalBaz',
name: 'experiment baz',
summary: 'top secret',
},
}
expect(result).to.deep.equal(expected)
})
})
})