@@ -247,7 +247,7 @@ export default function (fetchMock, assert) {
247
247
} ) ;
248
248
} ) ;
249
249
250
- assert . test ( t => { // Testing when we start with cached data and not expired (lastUpdate item higher than expirationTimestamp )
250
+ assert . test ( t => { // Testing when we start with cached data and not expired (lastUpdate timestamp higher than default (10) expirationDays ago )
251
251
const testUrls = {
252
252
sdk : 'https://sdk.baseurl/readyFromCacheWithData3' ,
253
253
events : 'https://events.baseurl/readyFromCacheWithData3'
@@ -365,7 +365,7 @@ export default function (fetchMock, assert) {
365
365
} ) ;
366
366
} ) ;
367
367
368
- assert . test ( t => { // Testing when we start with cached data but expired (lastUpdate item lower than expirationTimestamp )
368
+ assert . test ( t => { // Testing when we start with cached data but expired (lastUpdate timestamp lower than custom (1) expirationDays ago )
369
369
const testUrls = {
370
370
sdk : 'https://sdk.baseurl/readyFromCacheWithData4' ,
371
371
events : 'https://events.baseurl/readyFromCacheWithData4'
@@ -375,7 +375,8 @@ export default function (fetchMock, assert) {
375
375
fetchMock . get ( testUrls . sdk + '/splitChanges?s=1.2&since=-1' , function ( ) {
376
376
t . equal ( localStorage . getItem ( 'some_user_item' ) , 'user_item' , 'user items at localStorage must not be changed' ) ;
377
377
t . equal ( localStorage . getItem ( 'readyFromCache_4.SPLITIO.hash' ) , expectedHashNullFilter , 'storage hash must not be changed' ) ;
378
- t . equal ( localStorage . length , 2 , 'feature flags cache data must be cleaned from localStorage' ) ;
378
+ t . true ( nearlyEqual ( parseInt ( localStorage . getItem ( 'readyFromCache_4.SPLITIO.lastClear' ) , 10 ) , Date . now ( ) ) , 'storage lastClear timestamp must be updated' ) ;
379
+ t . equal ( localStorage . length , 3 , 'feature flags cache data must be cleaned from localStorage' ) ;
379
380
return { status : 200 , body : splitChangesMock1 } ;
380
381
} ) ;
381
382
fetchMock . get ( testUrls . sdk + '/splitChanges?s=1.2&since=1457552620999' , { status : 200 , body : splitChangesMock2 } ) ;
@@ -393,7 +394,7 @@ export default function (fetchMock, assert) {
393
394
394
395
localStorage . setItem ( 'some_user_item' , 'user_item' ) ;
395
396
localStorage . setItem ( 'readyFromCache_4.SPLITIO.splits.till' , 25 ) ;
396
- localStorage . setItem ( 'readyFromCache_4.SPLITIO.splits.lastUpdated' , Date . now ( ) - DEFAULT_CACHE_EXPIRATION_IN_MILLIS - 1 ) ; // -1 to ensure having an expired lastUpdated item
397
+ localStorage . setItem ( 'readyFromCache_4.SPLITIO.splits.lastUpdated' , Date . now ( ) - DEFAULT_CACHE_EXPIRATION_IN_MILLIS / 10 - 1 ) ; // -1 to ensure having an expired lastUpdated item
397
398
localStorage . setItem ( 'readyFromCache_4.SPLITIO.split.always_on' , alwaysOnSplitInverted ) ;
398
399
localStorage . setItem ( 'readyFromCache_4.SPLITIO.hash' , expectedHashNullFilter ) ;
399
400
@@ -402,7 +403,8 @@ export default function (fetchMock, assert) {
402
403
...baseConfig ,
403
404
storage : {
404
405
type : 'LOCALSTORAGE' ,
405
- prefix : 'readyFromCache_4'
406
+ prefix : 'readyFromCache_4' ,
407
+ expirationDays : 1 ,
406
408
} ,
407
409
startup : {
408
410
readyTimeout : 0.85
@@ -650,7 +652,8 @@ export default function (fetchMock, assert) {
650
652
...baseConfig ,
651
653
storage : {
652
654
type : 'LOCALSTORAGE' ,
653
- prefix : 'readyFromCache_7'
655
+ prefix : 'readyFromCache_7' ,
656
+ expirationDays : 0 , // invalid value, will use default (10)
654
657
} ,
655
658
urls : testUrls ,
656
659
sync : {
0 commit comments