You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
t.equal(client.getTreatment('emi@harness.io','non_existent_flag'),'control','The evaluation will return `control` if the flag does not exist and no fallbackTreatment is defined');
29
29
t.equal(client.getTreatment('emma@harness.io','non_existent_flag_2'),'control','The evaluation will return `control` if the flag does not exist and no fallbackTreatment is defined');
assert.test('FallbackTreatment / Split factory with global fallbackTreatment defined',asynct=>{
37
37
38
-
constconfig=Object.assign({},baseConfig);
39
-
config.fallbackTreatments={
40
-
global: 'FALLBACK_TREATMENT'
38
+
constconfig={
39
+
...baseConfig,
40
+
fallbackTreatments: {
41
+
global: 'FALLBACK_TREATMENT'
42
+
}
41
43
};
42
44
constsplitio=SplitFactory(config);
43
45
constclient=splitio.client();
44
46
45
-
awaitclient.ready();
47
+
awaitclient.whenReady();
46
48
47
49
48
50
t.equal(client.getTreatment('emi@harness.io','non_existent_flag'),'FALLBACK_TREATMENT','The evaluation will return `FALLBACK_TREATMENT` if the flag does not exist and no fallbackTreatment is defined');
assert.test('FallbackTreatment / Split factory with specific fallbackTreatment defined',asynct=>{
57
59
58
-
constconfig=Object.assign({},baseConfig);
59
-
config.fallbackTreatments={
60
-
byFlag: {
61
-
'non_existent_flag': 'FALLBACK_TREATMENT',
60
+
constconfig={
61
+
...baseConfig,
62
+
fallbackTreatments: {
63
+
byFlag: {
64
+
'non_existent_flag': 'FALLBACK_TREATMENT',
65
+
}
62
66
}
63
67
};
64
68
constsplitio=SplitFactory(config);
65
69
constclient=splitio.client();
66
70
67
-
awaitclient.ready();
71
+
awaitclient.whenReady();
68
72
69
73
t.equal(client.getTreatment('emi@harness.io','non_existent_flag'),'FALLBACK_TREATMENT','The evaluation will return `FALLBACK_TREATMENT` if the flag does not exist and no fallbackTreatment is defined');
70
74
t.equal(client.getTreatment('emi@harness.io','non_existent_flag_2'),'control','The evaluation will return `control` if the flag does not exist and no fallbackTreatment is defined');
assert.test('FallbackTreatment / flag override beats global fallbackTreatment',asynct=>{
82
86
83
-
constconfig=Object.assign({},baseConfig);
84
-
config.fallbackTreatments={
85
-
global: 'OFF_FALLBACK',
86
-
byFlag: {
87
-
'my_flag': 'ON_FALLBACK',
87
+
constconfig={
88
+
...baseConfig,
89
+
fallbackTreatments: {
90
+
global: 'OFF_FALLBACK',
91
+
byFlag: {
92
+
'my_flag': 'ON_FALLBACK',
93
+
}
88
94
}
89
95
};
90
96
constsplitio=SplitFactory(config);
91
97
constclient=splitio.client();
92
98
93
-
awaitclient.ready();
99
+
awaitclient.whenReady();
94
100
95
101
t.equal(client.getTreatment('emi@harness.io','my_flag'),'ON_FALLBACK','The evaluation will return `ON_FALLBACK` if the flag does not exist and no fallbackTreatment is defined');
96
102
t.equal(client.getTreatment('emi@harness.io','non_existent_flag_2'),'OFF_FALLBACK','The evaluation will return `OFF_FALLBACK` if the flag does not exist and no fallbackTreatment is defined');
assert.test('FallbackTreatment / override applies only when original is control',asynct=>{
107
113
108
-
constconfig=Object.assign({},baseConfig);
109
-
config.fallbackTreatments={
110
-
global: 'OFF_FALLBACK'
114
+
constconfig={
115
+
...baseConfig,
116
+
fallbackTreatments: {
117
+
global: 'OFF_FALLBACK'
118
+
}
111
119
};
112
120
constsplitio=SplitFactory(config);
113
121
constclient=splitio.client();
114
122
115
-
awaitclient.ready();
123
+
awaitclient.whenReady();
116
124
117
125
t.equal(client.getTreatment('emma@harness.io','user_account_in_whitelist'),'off','The evaluation will return the treatment defined in the flag if it exists');
118
126
t.equal(client.getTreatment('emma@harness.io','non_existent_flag'),'OFF_FALLBACK','The evaluation will return `OFF_FALLBACK` if the flag does not exist and no fallbackTreatment is defined');
t.equal(client.getTreatment('emi@harness.io','any_flag'),'OFF_FALLBACK','The evaluation will return the fallbackTreatment if the client is not ready yet');
140
150
t.equal(client.getTreatment('emma@harness.io','user_account_in_whitelist'),'control','The evaluation will return the fallbackTreatment if the client is not ready yet');
t.deepEqual(client.getTreatmentWithConfig('emma@harness.io','my_flag'),{treatment: 'ON_FALLBACK',config: '{"flag": true}'},'The evaluation will propagate the config along with the treatment from the fallbackTreatment');
180
192
t.deepEqual(client.getTreatmentWithConfig('emma@harness.io','non_existent_flag'),{treatment: 'OFF_FALLBACK',config: '{"global": true}'},'The evaluation will propagate the config along with the treatment from the fallbackTreatment');
t.deepEqual(client.getTreatmentWithConfig('emma@harness.io','my_flag'),{treatment: 'ON_FALLBACK',config: '{"flag": true}'},'The evaluation will propagate the config along with the treatment from the fallbackTreatment');
207
221
t.deepEqual(client.getTreatmentWithConfig('emma@harness.io','non_existent_flag'),{treatment: 'OFF_FALLBACK',config: '{"global": true}'},'The evaluation will propagate the config along with the treatment from the fallbackTreatment');
t.deepEqual(client.getTreatment('emma@harness.io','testing_split_on'),'on','The evaluation should return the treatment defined in localhost mode');
249
268
t.deepEqual(client.getTreatment('emma@harness.io','non_existent_flag'),'OFF_FALLBACK','The evaluation will return `OFF_FALLBACK` if the flag does not exist');
0 commit comments