Skip to content

Commit 413fff5

Browse files
Merge pull request #741 from splitio/tests_polishing
Tests polishing
2 parents fd5a200 + 5353a66 commit 413fff5

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

src/__tests__/browserSuites/ready-promise.spec.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -418,11 +418,10 @@ export default function readyPromiseAssertions(fetchMock, assert) {
418418
// We also use the manager to get some of the promises
419419
const manager = splitio.manager();
420420

421-
// promise1 is handled immediately. Thus, the 'reject' callback is expected to be called in 0.15 seconds aprox.
421+
// `ready` is called immediately. Thus, the 'reject' callback is expected to be called in 0.15 seconds aprox.
422422
setTimeout(() => {
423-
const promise1 = client.ready();
424423
const tStart = Date.now();
425-
promise1
424+
client.ready()
426425
.then(() => {
427426
t.fail('### SDK IS READY - not TIMED OUT when it should.');
428427
})
@@ -434,11 +433,10 @@ export default function readyPromiseAssertions(fetchMock, assert) {
434433
});
435434
}, 0);
436435

437-
// promise2 is handled in 0.15 seconds, when the promise is just rejected. Thus, the 'reject' callback is expected to be called immediately (0 seconds aprox).
436+
// `ready` is called in 0.15 seconds, when the promise is just rejected. Thus, the 'reject' callback is expected to be called immediately (0 seconds aprox).
438437
setTimeout(() => {
439-
const promise2 = manager.ready();
440438
const tStart = Date.now();
441-
promise2
439+
manager.ready()
442440
.then(() => {
443441
t.fail('### SDK IS READY - not TIMED OUT when it should.');
444442
})
@@ -450,11 +448,10 @@ export default function readyPromiseAssertions(fetchMock, assert) {
450448
});
451449
}, fromSecondsToMillis(0.15));
452450

453-
// promise3 is handled in 0.2 seconds, when the promise is just resolved. Thus, the 'resolve' callback is expected to be called immediately (0 seconds aprox).
451+
// `ready` is called in 0.25 seconds, right after the promise is resolved (0.2 secs). Thus, the 'resolve' callback is expected to be called immediately (0 seconds aprox).
454452
setTimeout(() => {
455-
const promise3 = manager.ready();
456453
const tStart = Date.now();
457-
promise3
454+
manager.ready()
458455
.then(() => {
459456
t.pass('### SDK IS READY - retry attempt finishes before the requestTimeoutBeforeReady limit');
460457
assertGetTreatmentWhenReady(t, client);
@@ -480,7 +477,7 @@ export default function readyPromiseAssertions(fetchMock, assert) {
480477
});
481478
});
482479
});
483-
}, fromSecondsToMillis(0.2));
480+
}, fromSecondsToMillis(0.25));
484481
}, 'Evaluate that multiple promises are resolved/rejected on expected times.');
485482

486483
// Validate that warning messages are properly sent.

src/__tests__/nodeSuites/ready-promise.spec.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,10 @@ export default function readyPromiseAssertions(key, fetchMock, assert) {
389389
// We also use the manager to get some of the promises
390390
const manager = splitio.manager();
391391

392-
// promise1 is handled immediately. Thus, the 'reject' callback is expected to be called in 0.15 seconds aprox.
392+
// `ready` is called immediately. Thus, the 'reject' callback is expected to be called in 0.15 seconds aprox.
393393
setTimeout(() => {
394-
const promise1 = client.ready();
395394
const tStart = Date.now();
396-
promise1
395+
client.ready()
397396
.then(() => {
398397
t.fail('### SDK IS READY - not TIMED OUT when it should.');
399398
})
@@ -405,11 +404,10 @@ export default function readyPromiseAssertions(key, fetchMock, assert) {
405404
});
406405
}, 0);
407406

408-
// promise2 is handled in 0.15 seconds, when the promise is just rejected. Thus, the 'reject' callback is expected to be called immediately (0 seconds aprox).
407+
// `ready` is called in 0.15 seconds, when the promise is just rejected. Thus, the 'reject' callback is expected to be called immediately (0 seconds aprox).
409408
setTimeout(() => {
410-
const promise2 = manager.ready();
411409
const tStart = Date.now();
412-
promise2
410+
manager.ready()
413411
.then(() => {
414412
t.fail('### SDK IS READY - not TIMED OUT when it should.');
415413
})
@@ -421,11 +419,10 @@ export default function readyPromiseAssertions(key, fetchMock, assert) {
421419
});
422420
}, fromSecondsToMillis(0.15));
423421

424-
// promise3 is handled in 0.2 seconds, when the promise is just resolved. Thus, the 'resolve' callback is expected to be called immediately (0 seconds aprox).
422+
// `ready` is called in 0.25 seconds, right after the promise is resolved (0.2 secs). Thus, the 'resolve' callback is expected to be called immediately (0 seconds aprox).
425423
setTimeout(() => {
426-
const promise3 = manager.ready();
427424
const tStart = Date.now();
428-
promise3
425+
manager.ready()
429426
.then(() => {
430427
t.pass('### SDK IS READY - retry attempt finishes before the requestTimeoutBeforeReady limit');
431428
assertGetTreatmentWhenReady(t, client, key);
@@ -451,7 +448,7 @@ export default function readyPromiseAssertions(key, fetchMock, assert) {
451448
});
452449
});
453450
});
454-
}, fromSecondsToMillis(0.2));
451+
}, fromSecondsToMillis(0.25));
455452
}, 'Evaluate that multiple promises are resolved/rejected on expected times.');
456453

457454
// Validate that warning messages are properly sent.

0 commit comments

Comments
 (0)