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
returnnewPromise(res=>{setTimeout(()=>res({status: 200,body: {ff: { ...splitChangesMock1.ff,s: 25}},headers: {}}),200);});// 400ms is how long it'll take to reply with Splits, no SDK_READY should be emitted before that.
@@ -225,7 +225,8 @@ export default function (fetchMock, assert) {
t.false(metadata.initialCacheLoad,'SDK_READY_FROM_CACHE from cache should have initialCacheLoad false');
229
230
t.true(Date.now()-startTime<400,'It should emit SDK_READY_FROM_CACHE on every client if there was data in the cache and we subscribe on time. Should be considerably faster than actual readiness from the cloud.');
230
231
t.equal(client.getTreatment('always_on'),'off','It should evaluate treatments with data from cache instead of control due to Input Validation');
231
232
});
@@ -238,7 +239,8 @@ export default function (fetchMock, assert) {
238
239
t.equal(client3.getTreatment('always_on'),'off','It should evaluate treatments with data from cache instead of control due to Input Validation');
239
240
});
240
241
241
-
client.on(client.Event.SDK_READY,()=>{
242
+
client.on(client.Event.SDK_READY,(metadata)=>{
243
+
t.false(metadata.initialCacheLoad,'SDK_READY when from cache first should have initialCacheLoad false');
242
244
t.true(Date.now()-startTime>=400,'It should emit SDK_READY too but after syncing with the cloud.');
243
245
t.equal(client.getTreatment('always_on'),'on','It should evaluate treatments with updated data after syncing with the cloud.');
244
246
});
@@ -371,8 +373,8 @@ export default function (fetchMock, assert) {
371
373
t.true(Date.now()-startTime>=400,'It should emit SDK_READY too but after syncing with the cloud.');
372
374
t.equal(client.getTreatment('always_on'),'on','It should evaluate treatments with updated data after syncing with the cloud.');
373
375
});
374
-
client.whenReadyFromCache().then((isReady)=>{
375
-
t.false(isReady,'It should be ready from cache before ready (syncing with the cloud).');
376
+
client.whenReadyFromCache().then((metadata)=>{
377
+
t.false(metadata.initialCacheLoad,'It should be ready from cache before ready (syncing with the cloud).');
376
378
t.true(Date.now()-startTime<50,'It should resolve ready from cache promise almost immediately.');
377
379
});
378
380
client.whenReady().then(()=>{
@@ -383,8 +385,8 @@ export default function (fetchMock, assert) {
383
385
t.true(Date.now()-startTime>=700,'It should emit SDK_READY too but after syncing with the cloud.');
384
386
t.equal(client2.getTreatment('always_on'),'on','It should evaluate treatments with updated data after syncing with the cloud.');
385
387
});
386
-
client2.whenReadyFromCache().then((isReady)=>{
387
-
t.false(isReady,'It should be ready from cache before ready (syncing with the cloud).');
388
+
client2.whenReadyFromCache().then((metadata)=>{
389
+
t.false(metadata.initialCacheLoad,'It should be ready from cache before ready (syncing with the cloud).');
388
390
});
389
391
client2.whenReady().then(()=>{
390
392
t.true(Date.now()-startTime>=700,'It should resolve ready promise after syncing with the cloud.');
@@ -474,7 +476,9 @@ export default function (fetchMock, assert) {
Copy file name to clipboardExpand all lines: src/__tests__/browserSuites/ready-promise.spec.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -521,7 +521,7 @@ export default function readyPromiseAssertions(fetchMock, assert) {
521
521
522
522
consoleSpy.log.resetHistory();
523
523
setTimeout(()=>{
524
-
client.whenReadyFromCache().then((isReady)=>t.true(isReady,'SDK IS READY (& READY FROM CACHE) - Should resolve')).catch(()=>t.fail('SDK TIMED OUT - Should not reject'));
524
+
client.whenReadyFromCache().then((metadata)=>t.true(metadata.initialCacheLoad,'SDK IS READY (& READY FROM CACHE) - Should resolve')).catch(()=>t.fail('SDK TIMED OUT - Should not reject'));
0 commit comments