@@ -247,7 +247,7 @@ export default function (fetchMock, assert) {
247247 } ) ;
248248 } ) ;
249249
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 )
251251 const testUrls = {
252252 sdk : 'https://sdk.baseurl/readyFromCacheWithData3' ,
253253 events : 'https://events.baseurl/readyFromCacheWithData3'
@@ -365,7 +365,7 @@ export default function (fetchMock, assert) {
365365 } ) ;
366366 } ) ;
367367
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 )
369369 const testUrls = {
370370 sdk : 'https://sdk.baseurl/readyFromCacheWithData4' ,
371371 events : 'https://events.baseurl/readyFromCacheWithData4'
@@ -375,7 +375,8 @@ export default function (fetchMock, assert) {
375375 fetchMock . get ( testUrls . sdk + '/splitChanges?s=1.2&since=-1' , function ( ) {
376376 t . equal ( localStorage . getItem ( 'some_user_item' ) , 'user_item' , 'user items at localStorage must not be changed' ) ;
377377 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' ) ;
379380 return { status : 200 , body : splitChangesMock1 } ;
380381 } ) ;
381382 fetchMock . get ( testUrls . sdk + '/splitChanges?s=1.2&since=1457552620999' , { status : 200 , body : splitChangesMock2 } ) ;
@@ -393,7 +394,7 @@ export default function (fetchMock, assert) {
393394
394395 localStorage . setItem ( 'some_user_item' , 'user_item' ) ;
395396 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
397398 localStorage . setItem ( 'readyFromCache_4.SPLITIO.split.always_on' , alwaysOnSplitInverted ) ;
398399 localStorage . setItem ( 'readyFromCache_4.SPLITIO.hash' , expectedHashNullFilter ) ;
399400
@@ -402,7 +403,8 @@ export default function (fetchMock, assert) {
402403 ...baseConfig ,
403404 storage : {
404405 type : 'LOCALSTORAGE' ,
405- prefix : 'readyFromCache_4'
406+ prefix : 'readyFromCache_4' ,
407+ expirationDays : 1 ,
406408 } ,
407409 startup : {
408410 readyTimeout : 0.85
@@ -650,7 +652,8 @@ export default function (fetchMock, assert) {
650652 ...baseConfig ,
651653 storage : {
652654 type : 'LOCALSTORAGE' ,
653- prefix : 'readyFromCache_7'
655+ prefix : 'readyFromCache_7' ,
656+ expirationDays : 0 , // invalid value, will use default (10)
654657 } ,
655658 urls : testUrls ,
656659 sync : {
0 commit comments