@@ -4,7 +4,7 @@ import type {OnyxKey, Selector} from '../../lib';
44import Onyx from '../../lib' ;
55import StorageMock from '../../lib/storage' ;
66import OnyxCache from '../../lib/OnyxCache' ;
7- import OnyxUtils from '../../lib/OnyxUtils' ;
7+ import OnyxUtils , { clearOnyxUtilsInternals } from '../../lib/OnyxUtils' ;
88import type GenericCollection from '../utils/GenericCollection' ;
99import type { Mapping , OnyxUpdate } from '../../lib/Onyx' ;
1010import createDeferredTask from '../../lib/createDeferredTask' ;
@@ -44,6 +44,7 @@ const mockedReportActionsMap = getRandomReportActions(collectionKey);
4444const mockedReportActionsKeys = Object . keys ( mockedReportActionsMap ) ;
4545
4646const clearOnyxAfterEachMeasure = async ( ) => {
47+ clearOnyxUtilsInternals ( ) ;
4748 await Onyx . clear ( ) ;
4849} ;
4950
@@ -59,6 +60,7 @@ describe('OnyxUtils', () => {
5960 } ) ;
6061
6162 afterEach ( async ( ) => {
63+ clearOnyxUtilsInternals ( ) ;
6264 await Onyx . clear ( ) ;
6365 } ) ;
6466
@@ -321,14 +323,14 @@ describe('OnyxUtils', () => {
321323 } ) ;
322324 } ,
323325 afterEach : async ( ) => {
324- await clearOnyxAfterEachMeasure ( ) ;
325326 mockedReportActionsKeys . forEach ( ( key ) => {
326327 const id = subscriptionMap . get ( key ) ;
327328 if ( id ) {
328329 OnyxUtils . unsubscribeFromKey ( id ) ;
329330 }
330331 } ) ;
331332 subscriptionMap . clear ( ) ;
333+ await clearOnyxAfterEachMeasure ( ) ;
332334 } ,
333335 } ) ;
334336 } ) ;
@@ -351,11 +353,11 @@ describe('OnyxUtils', () => {
351353 }
352354 } ,
353355 afterEach : async ( ) => {
354- await clearOnyxAfterEachMeasure ( ) ;
355356 subscriptionIDs . forEach ( ( id ) => {
356357 OnyxUtils . unsubscribeFromKey ( id ) ;
357358 } ) ;
358359 subscriptionIDs . clear ( ) ;
360+ await clearOnyxAfterEachMeasure ( ) ;
359361 } ,
360362 } ) ;
361363 } ) ;
@@ -384,10 +386,10 @@ describe('OnyxUtils', () => {
384386 subscriptionID = OnyxUtils . subscribeToKey ( { key : collectionKey , callback : jest . fn ( ) , initWithStoredValues : false } ) ;
385387 } ,
386388 afterEach : async ( ) => {
387- await clearOnyxAfterEachMeasure ( ) ;
388389 if ( subscriptionID ) {
389390 OnyxUtils . unsubscribeFromKey ( subscriptionID ) ;
390391 }
392+ await clearOnyxAfterEachMeasure ( ) ;
391393 } ,
392394 } ,
393395 ) ;
@@ -417,10 +419,10 @@ describe('OnyxUtils', () => {
417419 subscriptionID = OnyxUtils . subscribeToKey ( { key : collectionKey , callback : jest . fn ( ) , initWithStoredValues : false } ) ;
418420 } ,
419421 afterEach : async ( ) => {
420- await clearOnyxAfterEachMeasure ( ) ;
421422 if ( subscriptionID ) {
422423 OnyxUtils . unsubscribeFromKey ( subscriptionID ) ;
423424 }
425+ await clearOnyxAfterEachMeasure ( ) ;
424426 } ,
425427 } ,
426428 ) ;
@@ -466,10 +468,10 @@ describe('OnyxUtils', () => {
466468 await Onyx . multiSet ( mockedReportActionsMap ) ;
467469 } ,
468470 afterEach : async ( ) => {
469- await clearOnyxAfterEachMeasure ( ) ;
470471 if ( subscriptionID ) {
471472 OnyxUtils . unsubscribeFromKey ( subscriptionID ) ;
472473 }
474+ await clearOnyxAfterEachMeasure ( ) ;
473475 } ,
474476 } ,
475477 ) ;
@@ -495,14 +497,14 @@ describe('OnyxUtils', () => {
495497 } ) ;
496498 } ,
497499 afterEach : async ( ) => {
498- await clearOnyxAfterEachMeasure ( ) ;
499500 mockedReportActionsKeys . forEach ( ( key ) => {
500501 const id = subscriptionMap . get ( key ) ;
501502 if ( id ) {
502503 OnyxUtils . unsubscribeFromKey ( id ) ;
503504 }
504505 } ) ;
505506 subscriptionMap . clear ( ) ;
507+ await clearOnyxAfterEachMeasure ( ) ;
506508 } ,
507509 } ,
508510 ) ;
@@ -526,14 +528,14 @@ describe('OnyxUtils', () => {
526528 } ) ;
527529 } ,
528530 afterEach : async ( ) => {
529- await clearOnyxAfterEachMeasure ( ) ;
530531 mockedReportActionsKeys . forEach ( ( key ) => {
531532 const id = subscriptionMap . get ( key ) ;
532533 if ( id ) {
533534 OnyxUtils . unsubscribeFromKey ( id ) ;
534535 }
535536 } ) ;
536537 subscriptionMap . clear ( ) ;
538+ await clearOnyxAfterEachMeasure ( ) ;
537539 } ,
538540 } ) ;
539541 } ) ;
@@ -726,8 +728,8 @@ describe('OnyxUtils', () => {
726728 await StorageMock . multiSet ( Object . entries ( mockedReportActionsMap ) . map ( ( [ k , v ] ) => [ k , v ] ) ) ;
727729 } ,
728730 afterEach : async ( ) => {
729- await clearOnyxAfterEachMeasure ( ) ;
730731 OnyxUtils . unsubscribeFromKey ( subscriptionID ) ;
732+ await clearOnyxAfterEachMeasure ( ) ;
731733 } ,
732734 } ,
733735 ) ;
@@ -753,8 +755,8 @@ describe('OnyxUtils', () => {
753755 await StorageMock . multiSet ( Object . entries ( mockedReportActionsMap ) . map ( ( [ k , v ] ) => [ k , v ] ) ) ;
754756 } ,
755757 afterEach : async ( ) => {
756- await clearOnyxAfterEachMeasure ( ) ;
757758 OnyxUtils . unsubscribeFromKey ( subscriptionID ) ;
759+ await clearOnyxAfterEachMeasure ( ) ;
758760 } ,
759761 } ,
760762 ) ;
@@ -822,9 +824,9 @@ describe('OnyxUtils', () => {
822824 } ) ;
823825 } ,
824826 afterEach : async ( ) => {
825- await clearOnyxAfterEachMeasure ( ) ;
826827 OnyxUtils . deleteKeyBySubscriptions ( subscriptionID ) ;
827828 OnyxUtils . unsubscribeFromKey ( subscriptionID ) ;
829+ await clearOnyxAfterEachMeasure ( ) ;
828830 } ,
829831 } ) ;
830832 } ) ;
@@ -844,8 +846,8 @@ describe('OnyxUtils', () => {
844846 OnyxUtils . storeKeyBySubscriptions ( key , subscriptionID ) ;
845847 } ,
846848 afterEach : async ( ) => {
847- await clearOnyxAfterEachMeasure ( ) ;
848849 OnyxUtils . unsubscribeFromKey ( subscriptionID ) ;
850+ await clearOnyxAfterEachMeasure ( ) ;
849851 } ,
850852 } ) ;
851853 } ) ;
@@ -865,8 +867,8 @@ describe('OnyxUtils', () => {
865867 } ) ,
866868 {
867869 afterEach : async ( ) => {
868- await clearOnyxAfterEachMeasure ( ) ;
869870 OnyxCache . removeLastAccessedKey ( key ) ;
871+ await clearOnyxAfterEachMeasure ( ) ;
870872 } ,
871873 } ,
872874 ) ;
0 commit comments