Skip to content

Commit

Permalink
Use fake timers
Browse files Browse the repository at this point in the history
  • Loading branch information
ciampo committed May 3, 2022
1 parent 1671e34 commit 3710490
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/components/src/unit-control/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import type { UnitControlOnChangeCallback } from '../types';
function render( jsx: React.ReactElement ) {
return {
user: userEvent.setup( {
// Avoids timeout errors (https://github.com/testing-library/user-event/issues/565#issuecomment-1064579531).
delay: null,
advanceTimers: jest.advanceTimersByTime,
} ),
...RTLrender( jsx ),
};
Expand Down Expand Up @@ -98,6 +97,15 @@ const ControlledSyncUnits = () => {
};

describe( 'UnitControl', () => {
beforeEach( () => {
jest.useFakeTimers();
} );

afterEach( () => {
jest.runOnlyPendingTimers();
jest.useRealTimers();
} );

describe( 'Basic rendering', () => {
it( 'should render', () => {
render( <UnitControl /> );
Expand Down

0 comments on commit 3710490

Please sign in to comment.