@@ -737,7 +737,7 @@ describe('useOnyx', () => {
737737 } ) ;
738738 } ) ;
739739
740- describe ( 'allowStaleData ' , ( ) => {
740+ describe ( 'pending merges ' , ( ) => {
741741 it ( 'should return undefined and loading state while we have pending merges for the key, and then return updated value and loaded state' , async ( ) => {
742742 Onyx . set ( ONYXKEYS . TEST_KEY , 'test1' ) ;
743743
@@ -777,24 +777,6 @@ describe('useOnyx', () => {
777777 expect ( result . current [ 0 ] ) . toEqual ( 'test4_changed' ) ;
778778 expect ( result . current [ 1 ] . status ) . toEqual ( 'loaded' ) ;
779779 } ) ;
780-
781- it ( 'should return stale value and loaded state if allowStaleData is true, and then return updated value and loaded state' , async ( ) => {
782- Onyx . set ( ONYXKEYS . TEST_KEY , 'test1' ) ;
783-
784- Onyx . merge ( ONYXKEYS . TEST_KEY , 'test2' ) ;
785- Onyx . merge ( ONYXKEYS . TEST_KEY , 'test3' ) ;
786- Onyx . merge ( ONYXKEYS . TEST_KEY , 'test4' ) ;
787-
788- const { result} = renderHook ( ( ) => useOnyx ( ONYXKEYS . TEST_KEY , { allowStaleData : true } ) ) ;
789-
790- expect ( result . current [ 0 ] ) . toEqual ( 'test1' ) ;
791- expect ( result . current [ 1 ] . status ) . toEqual ( 'loaded' ) ;
792-
793- await act ( async ( ) => waitForPromisesToResolve ( ) ) ;
794-
795- expect ( result . current [ 0 ] ) . toEqual ( 'test4' ) ;
796- expect ( result . current [ 1 ] . status ) . toEqual ( 'loaded' ) ;
797- } ) ;
798780 } ) ;
799781
800782 describe ( 'initWithStoredValues' , ( ) => {
@@ -877,39 +859,6 @@ describe('useOnyx', () => {
877859 expect ( result2 . current [ 1 ] . status ) . toEqual ( 'loaded' ) ;
878860 } ) ;
879861
880- it ( '"allowStaleData" should work correctly for the same key if more than one hook is using it' , async ( ) => {
881- Onyx . set ( ONYXKEYS . TEST_KEY , 'test1' ) ;
882-
883- Onyx . merge ( ONYXKEYS . TEST_KEY , 'test2' ) ;
884- Onyx . merge ( ONYXKEYS . TEST_KEY , 'test3' ) ;
885- Onyx . merge ( ONYXKEYS . TEST_KEY , 'test4' ) ;
886-
887- const { result : result1 } = renderHook ( ( ) => useOnyx ( ONYXKEYS . TEST_KEY , { allowStaleData : true } ) ) ;
888-
889- expect ( result1 . current [ 0 ] ) . toEqual ( 'test1' ) ;
890- expect ( result1 . current [ 1 ] . status ) . toEqual ( 'loaded' ) ;
891-
892- await act ( async ( ) => waitForPromisesToResolve ( ) ) ;
893-
894- expect ( result1 . current [ 0 ] ) . toEqual ( 'test4' ) ;
895- expect ( result1 . current [ 1 ] . status ) . toEqual ( 'loaded' ) ;
896-
897- // Second hook
898- Onyx . merge ( ONYXKEYS . TEST_KEY , 'test5' ) ;
899- Onyx . merge ( ONYXKEYS . TEST_KEY , 'test6' ) ;
900- Onyx . merge ( ONYXKEYS . TEST_KEY , 'test7' ) ;
901-
902- const { result : result2 } = renderHook ( ( ) => useOnyx ( ONYXKEYS . TEST_KEY , { allowStaleData : true } ) ) ;
903-
904- expect ( result2 . current [ 0 ] ) . toEqual ( 'test4' ) ;
905- expect ( result2 . current [ 1 ] . status ) . toEqual ( 'loaded' ) ;
906-
907- await act ( async ( ) => waitForPromisesToResolve ( ) ) ;
908-
909- expect ( result2 . current [ 0 ] ) . toEqual ( 'test7' ) ;
910- expect ( result2 . current [ 1 ] . status ) . toEqual ( 'loaded' ) ;
911- } ) ;
912-
913862 it ( '"initWithStoredValues" should work correctly for the same key if more than one hook is using it' , async ( ) => {
914863 await StorageMock . setItem ( ONYXKEYS . TEST_KEY , 'test1' ) ;
915864
0 commit comments