11import * as React from 'react' ;
2- import { render , waitFor , screen , act } from '@testing-library/react' ;
2+ import { render , waitFor , screen } from '@testing-library/react' ;
33import expect from 'expect' ;
44
55import { RaRecord } from '../types' ;
@@ -269,17 +269,13 @@ describe('useCreate', () => {
269269 } ) ;
270270 it ( 'when undoable, displays result and success side effects right away and fetched on confirm' , async ( ) => {
271271 render ( < SuccessCaseUndoable timeout = { 10 } /> ) ;
272- act ( ( ) => {
273- screen . getByText ( 'Create post' ) . click ( ) ;
274- } ) ;
272+ screen . getByText ( 'Create post' ) . click ( ) ;
275273 await waitFor ( ( ) => {
276274 expect ( screen . queryByText ( 'success' ) ) . not . toBeNull ( ) ;
277275 expect ( screen . queryByText ( 'Hello World' ) ) . not . toBeNull ( ) ;
278276 expect ( screen . queryByText ( 'mutating' ) ) . toBeNull ( ) ;
279277 } ) ;
280- act ( ( ) => {
281- screen . getByText ( 'Confirm' ) . click ( ) ;
282- } ) ;
278+ screen . getByText ( 'Confirm' ) . click ( ) ;
283279 await waitFor ( ( ) => {
284280 expect ( screen . queryByText ( 'success' ) ) . not . toBeNull ( ) ;
285281 expect ( screen . queryByText ( 'Hello World' ) ) . not . toBeNull ( ) ;
@@ -297,17 +293,13 @@ describe('useCreate', () => {
297293 it ( 'when undoable, displays result and success side effects right away and reverts on cancel' , async ( ) => {
298294 render ( < SuccessCaseUndoable timeout = { 10 } /> ) ;
299295 await screen . findByText ( 'not found' ) ;
300- act ( ( ) => {
301- screen . getByText ( 'Create post' ) . click ( ) ;
302- } ) ;
296+ screen . getByText ( 'Create post' ) . click ( ) ;
303297 await waitFor ( ( ) => {
304298 expect ( screen . queryByText ( 'success' ) ) . not . toBeNull ( ) ;
305299 expect ( screen . queryByText ( 'Hello World' ) ) . not . toBeNull ( ) ;
306300 expect ( screen . queryByText ( 'mutating' ) ) . toBeNull ( ) ;
307301 } ) ;
308- act ( ( ) => {
309- screen . getByText ( 'Cancel' ) . click ( ) ;
310- } ) ;
302+ screen . getByText ( 'Cancel' ) . click ( ) ;
311303 await waitFor ( ( ) => {
312304 expect ( screen . queryByText ( 'Hello World' ) ) . toBeNull ( ) ;
313305 } ) ;
@@ -424,17 +416,13 @@ describe('useCreate', () => {
424416
425417 it ( 'when undoable, it accepts middlewares and displays result and success side effects right away and fetched on confirm' , async ( ) => {
426418 render ( < WithMiddlewaresSuccessUndoable timeout = { 10 } /> ) ;
427- act ( ( ) => {
428- screen . getByText ( 'Create post' ) . click ( ) ;
429- } ) ;
419+ screen . getByText ( 'Create post' ) . click ( ) ;
430420 await waitFor ( ( ) => {
431421 expect ( screen . queryByText ( 'success' ) ) . not . toBeNull ( ) ;
432422 expect ( screen . queryByText ( 'Hello World' ) ) . not . toBeNull ( ) ;
433423 expect ( screen . queryByText ( 'mutating' ) ) . toBeNull ( ) ;
434424 } ) ;
435- act ( ( ) => {
436- screen . getByText ( 'Confirm' ) . click ( ) ;
437- } ) ;
425+ screen . getByText ( 'Confirm' ) . click ( ) ;
438426 await waitFor ( ( ) => {
439427 expect ( screen . queryByText ( 'success' ) ) . not . toBeNull ( ) ;
440428 expect ( screen . queryByText ( 'Hello World' ) ) . not . toBeNull ( ) ;
@@ -452,17 +440,13 @@ describe('useCreate', () => {
452440 it ( 'when undoable, it accepts middlewares and displays result and success side effects right away and reverts on cancel' , async ( ) => {
453441 render ( < WithMiddlewaresSuccessUndoable timeout = { 10 } /> ) ;
454442 await screen . findByText ( 'not found' ) ;
455- act ( ( ) => {
456- screen . getByText ( 'Create post' ) . click ( ) ;
457- } ) ;
443+ screen . getByText ( 'Create post' ) . click ( ) ;
458444 await waitFor ( ( ) => {
459445 expect ( screen . queryByText ( 'success' ) ) . not . toBeNull ( ) ;
460446 expect ( screen . queryByText ( 'Hello World' ) ) . not . toBeNull ( ) ;
461447 expect ( screen . queryByText ( 'mutating' ) ) . toBeNull ( ) ;
462448 } ) ;
463- act ( ( ) => {
464- screen . getByText ( 'Cancel' ) . click ( ) ;
465- } ) ;
449+ screen . getByText ( 'Cancel' ) . click ( ) ;
466450 await waitFor ( ( ) => {
467451 expect ( screen . queryByText ( 'Hello World' ) ) . toBeNull ( ) ;
468452 } ) ;
0 commit comments