@@ -1027,67 +1027,6 @@ describe('ReactDOMForm', () => {
10271027 expect ( container . textContent ) . toBe ( '2' ) ;
10281028 } ) ;
10291029
1030- // @gate enableFormActions
1031- // @gate enableAsyncActions
1032- test ( 'useActionState updates state asynchronously and queues multiple actions' , async ( ) => {
1033- let actionCounter = 0 ;
1034- async function action ( state , type ) {
1035- actionCounter ++ ;
1036-
1037- Scheduler . log ( `Async action started [${ actionCounter } ]` ) ;
1038- await getText ( `Wait [${ actionCounter } ]` ) ;
1039-
1040- switch ( type ) {
1041- case 'increment' :
1042- return state + 1 ;
1043- case 'decrement' :
1044- return state - 1 ;
1045- default :
1046- return state ;
1047- }
1048- }
1049-
1050- let dispatch ;
1051- function App ( ) {
1052- const [ state , _dispatch , isPending ] = useActionState ( action , 0 ) ;
1053- dispatch = _dispatch ;
1054- const pending = isPending ? 'Pending ' : '' ;
1055- return < Text text = { pending + state } /> ;
1056- }
1057-
1058- const root = ReactDOMClient . createRoot ( container ) ;
1059- await act ( ( ) => root . render ( < App /> ) ) ;
1060- assertLog ( [ '0' ] ) ;
1061- expect ( container . textContent ) . toBe ( '0' ) ;
1062-
1063- await act ( ( ) => dispatch ( 'increment' ) ) ;
1064- assertLog ( [ 'Async action started [1]' , 'Pending 0' ] ) ;
1065- expect ( container . textContent ) . toBe ( 'Pending 0' ) ;
1066-
1067- // Dispatch a few more actions. None of these will start until the previous
1068- // one finishes.
1069- await act ( ( ) => dispatch ( 'increment' ) ) ;
1070- await act ( ( ) => dispatch ( 'decrement' ) ) ;
1071- await act ( ( ) => dispatch ( 'increment' ) ) ;
1072- assertLog ( [ ] ) ;
1073-
1074- // Each action starts as soon as the previous one finishes.
1075- // NOTE: React does not render in between these actions because they all
1076- // update the same queue, which means they get entangled together. This is
1077- // intentional behavior.
1078- await act ( ( ) => resolveText ( 'Wait [1]' ) ) ;
1079- assertLog ( [ 'Async action started [2]' ] ) ;
1080- await act ( ( ) => resolveText ( 'Wait [2]' ) ) ;
1081- assertLog ( [ 'Async action started [3]' ] ) ;
1082- await act ( ( ) => resolveText ( 'Wait [3]' ) ) ;
1083- assertLog ( [ 'Async action started [4]' ] ) ;
1084- await act ( ( ) => resolveText ( 'Wait [4]' ) ) ;
1085-
1086- // Finally the last action finishes and we can render the result.
1087- assertLog ( [ '2' ] ) ;
1088- expect ( container . textContent ) . toBe ( '2' ) ;
1089- } ) ;
1090-
10911030 // @gate enableFormActions
10921031 // @gate enableAsyncActions
10931032 test ( 'useActionState supports inline actions' , async ( ) => {
0 commit comments