@@ -638,7 +638,7 @@ describe('Onyx', () => {
638638 } ) ;
639639
640640 it ( 'Should clean cache when connections to eviction keys happen' , ( ) => {
641- // Given Storage with 10 different keys
641+ // Given storage with some data
642642 StorageMock . getItem . mockResolvedValue ( '"mockValue"' ) ;
643643 const range = generateRange ( 0 , 10 ) ;
644644 const keyPrefix = ONYX_KEYS . COLLECTION . MOCK_COLLECTION ;
@@ -686,7 +686,6 @@ describe('Onyx', () => {
686686 const evictableKey1 = `${ testKeys . SAFE_FOR_EVICTION } 1` ;
687687 const evictableKey2 = `${ testKeys . SAFE_FOR_EVICTION } 2` ;
688688 const evictableKey3 = `${ testKeys . SAFE_FOR_EVICTION } 3` ;
689- // Additional key to trigger eviction
690689 const triggerKey = `${ testKeys . SAFE_FOR_EVICTION } trigger` ;
691690
692691 StorageMock . getItem . mockResolvedValue ( '"mockValue"' ) ;
@@ -703,11 +702,10 @@ describe('Onyx', () => {
703702 ] ;
704703 StorageMock . getAllKeys . mockResolvedValue ( allKeys ) ;
705704
706- // SAFE_FOR_EVICTION pattern will make all evictableKey* keys evictable
707705 return initOnyx ( {
708706 keys : testKeys ,
709- maxCachedKeysCount : 3 , // Only allow 3 keys in cache
710- evictableKeys : [ testKeys . SAFE_FOR_EVICTION ] , // This makes all evictable_* keys evictable
707+ maxCachedKeysCount : 3 ,
708+ evictableKeys : [ testKeys . SAFE_FOR_EVICTION ] ,
711709 } )
712710 . then ( ( ) => {
713711 // Verify keys are correctly identified as evictable or not
@@ -758,16 +756,15 @@ describe('Onyx', () => {
758756 NOT_SAFE_FOR_EVICTION : 'critical_' ,
759757 } ;
760758
761- const criticalKey1 = `${ testKeys . NOT_SAFE_FOR_EVICTION } 1` ; // Oldest key (first connected)
762- const criticalKey2 = `${ testKeys . NOT_SAFE_FOR_EVICTION } 2` ; // Second oldest
763- const criticalKey3 = `${ testKeys . NOT_SAFE_FOR_EVICTION } 3` ; // Most recent
764- const evictableKey1 = `${ testKeys . SAFE_FOR_EVICTION } 1` ; // Safe key to evict
759+ const criticalKey1 = `${ testKeys . NOT_SAFE_FOR_EVICTION } 1` ;
760+ const criticalKey2 = `${ testKeys . NOT_SAFE_FOR_EVICTION } 2` ;
761+ const criticalKey3 = `${ testKeys . NOT_SAFE_FOR_EVICTION } 3` ;
762+ const evictableKey1 = `${ testKeys . SAFE_FOR_EVICTION } 1` ;
765763 // Additional trigger key for natural eviction
766764 const triggerKey = `${ testKeys . SAFE_FOR_EVICTION } trigger` ;
767765
768766 StorageMock . getItem . mockResolvedValue ( '"mockValue"' ) ;
769767 const allKeys = [
770- // Only one key that's safe to evict
771768 evictableKey1 ,
772769 triggerKey ,
773770 // Keys that should not be evicted
@@ -777,14 +774,12 @@ describe('Onyx', () => {
777774 ] ;
778775 StorageMock . getAllKeys . mockResolvedValue ( allKeys ) ;
779776
780- // Both evictableKey1 and triggerKey should be evictable
781777 return initOnyx ( {
782778 keys : testKeys ,
783- maxCachedKeysCount : 2 , // Only allow 2 keys in cache
784- evictableKeys : [ testKeys . SAFE_FOR_EVICTION ] , // This pattern matches both evictable keys
779+ maxCachedKeysCount : 2 ,
780+ evictableKeys : [ testKeys . SAFE_FOR_EVICTION ] ,
785781 } )
786782 . then ( ( ) => {
787- // Connect to keys in LRU order (oldest first)
788783 Onyx . connect ( { key : criticalKey1 , callback : jest . fn ( ) } ) ; // Should never be evicted
789784 Onyx . connect ( { key : criticalKey2 , callback : jest . fn ( ) } ) ; // Should never be evicted
790785 Onyx . connect ( { key : criticalKey3 , callback : jest . fn ( ) } ) ; // Should never be evicted
@@ -798,7 +793,6 @@ describe('Onyx', () => {
798793 . then ( waitForPromisesToResolve )
799794 . then ( ( ) => {
800795 // evictableKey1 should be evicted since it's an evictable key
801- // and triggerKey is the most recently connected one
802796 expect ( cache . hasCacheForKey ( evictableKey1 ) ) . toBe ( false ) ;
803797
804798 // Non-evictable keys should remain in cache
0 commit comments