@@ -717,7 +717,7 @@ describe('useOnyx', () => {
717717 } ) ;
718718 } ) ;
719719
720- describe ( 'allowStaleData ' , ( ) => {
720+ describe ( 'pending merges ' , ( ) => {
721721 it ( 'should return undefined and loading state while we have pending merges for the key, and then return updated value and loaded state' , async ( ) => {
722722 Onyx . set ( ONYXKEYS . TEST_KEY , 'test1' ) ;
723723
@@ -757,24 +757,6 @@ describe('useOnyx', () => {
757757 expect ( result . current [ 0 ] ) . toEqual ( 'test4_changed' ) ;
758758 expect ( result . current [ 1 ] . status ) . toEqual ( 'loaded' ) ;
759759 } ) ;
760-
761- it ( 'should return stale value and loaded state if allowStaleData is true, and then return updated value and loaded state' , async ( ) => {
762- Onyx . set ( ONYXKEYS . TEST_KEY , 'test1' ) ;
763-
764- Onyx . merge ( ONYXKEYS . TEST_KEY , 'test2' ) ;
765- Onyx . merge ( ONYXKEYS . TEST_KEY , 'test3' ) ;
766- Onyx . merge ( ONYXKEYS . TEST_KEY , 'test4' ) ;
767-
768- const { result} = renderHook ( ( ) => useOnyx ( ONYXKEYS . TEST_KEY , { allowStaleData : true } ) ) ;
769-
770- expect ( result . current [ 0 ] ) . toEqual ( 'test1' ) ;
771- expect ( result . current [ 1 ] . status ) . toEqual ( 'loaded' ) ;
772-
773- await act ( async ( ) => waitForPromisesToResolve ( ) ) ;
774-
775- expect ( result . current [ 0 ] ) . toEqual ( 'test4' ) ;
776- expect ( result . current [ 1 ] . status ) . toEqual ( 'loaded' ) ;
777- } ) ;
778760 } ) ;
779761
780762 describe ( 'initWithStoredValues' , ( ) => {
@@ -857,39 +839,6 @@ describe('useOnyx', () => {
857839 expect ( result2 . current [ 1 ] . status ) . toEqual ( 'loaded' ) ;
858840 } ) ;
859841
860- it ( '"allowStaleData" should work correctly for the same key if more than one hook is using it' , async ( ) => {
861- Onyx . set ( ONYXKEYS . TEST_KEY , 'test1' ) ;
862-
863- Onyx . merge ( ONYXKEYS . TEST_KEY , 'test2' ) ;
864- Onyx . merge ( ONYXKEYS . TEST_KEY , 'test3' ) ;
865- Onyx . merge ( ONYXKEYS . TEST_KEY , 'test4' ) ;
866-
867- const { result : result1 } = renderHook ( ( ) => useOnyx ( ONYXKEYS . TEST_KEY , { allowStaleData : true } ) ) ;
868-
869- expect ( result1 . current [ 0 ] ) . toEqual ( 'test1' ) ;
870- expect ( result1 . current [ 1 ] . status ) . toEqual ( 'loaded' ) ;
871-
872- await act ( async ( ) => waitForPromisesToResolve ( ) ) ;
873-
874- expect ( result1 . current [ 0 ] ) . toEqual ( 'test4' ) ;
875- expect ( result1 . current [ 1 ] . status ) . toEqual ( 'loaded' ) ;
876-
877- // Second hook
878- Onyx . merge ( ONYXKEYS . TEST_KEY , 'test5' ) ;
879- Onyx . merge ( ONYXKEYS . TEST_KEY , 'test6' ) ;
880- Onyx . merge ( ONYXKEYS . TEST_KEY , 'test7' ) ;
881-
882- const { result : result2 } = renderHook ( ( ) => useOnyx ( ONYXKEYS . TEST_KEY , { allowStaleData : true } ) ) ;
883-
884- expect ( result2 . current [ 0 ] ) . toEqual ( 'test4' ) ;
885- expect ( result2 . current [ 1 ] . status ) . toEqual ( 'loaded' ) ;
886-
887- await act ( async ( ) => waitForPromisesToResolve ( ) ) ;
888-
889- expect ( result2 . current [ 0 ] ) . toEqual ( 'test7' ) ;
890- expect ( result2 . current [ 1 ] . status ) . toEqual ( 'loaded' ) ;
891- } ) ;
892-
893842 it ( '"initWithStoredValues" should work correctly for the same key if more than one hook is using it' , async ( ) => {
894843 await StorageMock . setItem ( ONYXKEYS . TEST_KEY , 'test1' ) ;
895844
0 commit comments