Skip to content

Commit cf950bc

Browse files
Fix tests
1 parent 352b8bc commit cf950bc

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

src/__tests__/browserSuites/evaluations-fallback.spec.js

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,7 @@ const listener = {
55
logImpression: sinon.stub()
66
};
77

8-
const baseConfig = {
9-
core: {
10-
authorizationKey: '<fake-token>',
11-
key: 'facundo@split.io'
12-
},
13-
sync: {
14-
impressionsMode: 'DEBUG'
15-
},
16-
streamingEnabled: false
17-
};
18-
19-
export default async function (fetchMock, assert) {
8+
export default function (baseConfig, fetchMock, assert) {
209

2110
assert.test('FallbackTreatment / Split factory with no fallbackTreatment defined', async t => {
2211

@@ -122,7 +111,7 @@ export default async function (fetchMock, assert) {
122111

123112
});
124113

125-
assert.test('FallbackTreatment / Impressions correctness with fallback when client is not whenReady', async t => {
114+
assert.test('FallbackTreatment / Impressions correctness with fallback when client is not ready', async t => {
126115

127116
const config = Object.assign({}, baseConfig);
128117
config.urls = {
@@ -136,8 +125,8 @@ export default async function (fetchMock, assert) {
136125
const splitio = SplitFactory(config);
137126
const client = splitio.client();
138127

139-
t.equal(client.getTreatment('any_flag'), 'OFF_FALLBACK', 'The evaluation will return the fallbackTreatment if the client is not whenReady yet');
140-
t.equal(client.getTreatment('user_account_in_whitelist'), 'control', 'The evaluation will return the fallbackTreatment if the client is not whenReady yet');
128+
t.equal(client.getTreatment('any_flag'), 'OFF_FALLBACK', 'The evaluation will return the fallbackTreatment if the client is not ready yet');
129+
t.equal(client.getTreatment('user_account_in_whitelist'), 'control', 'The evaluation will return the fallbackTreatment if the client is not ready yet');
141130

142131
await client.whenReady();
143132

@@ -151,8 +140,8 @@ export default async function (fetchMock, assert) {
151140
t.equal(impressions[0].r, expectedLabel, `${featureFlagName} impression with label ${expectedLabel}`);
152141
}
153142

154-
validateImpressionData('any_flag', 'fallback - not whenReady');
155-
validateImpressionData('user_account_in_whitelist', 'not whenReady');
143+
validateImpressionData('any_flag', 'fallback - not ready');
144+
validateImpressionData('user_account_in_whitelist', 'not ready');
156145
t.end();
157146

158147
return 200;
@@ -206,7 +195,7 @@ export default async function (fetchMock, assert) {
206195
t.deepEqual(client.getTreatmentWithConfig('my_flag'), { treatment: 'ON_FALLBACK', config: '{"flag": true}' }, 'The evaluation will propagate the config along with the treatment from the fallbackTreatment');
207196
t.deepEqual(client.getTreatmentWithConfig('non_existent_flag'), { treatment: 'OFF_FALLBACK', config: '{"global": true}' }, 'The evaluation will propagate the config along with the treatment from the fallbackTreatment');
208197

209-
let POSTED_IMPRESSIONS_COUNT;
198+
let POSTED_IMPRESSIONS_COUNT = 0;
210199

211200
fetchMock.postOnce(config.urls.events + '/testImpressions/bulk', (_, opts) => {
212201

0 commit comments

Comments
 (0)