Skip to content

Commit

Permalink
Tests: Cleanup unnecessary jest timers setup
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla committed Mar 13, 2023
1 parent c9b83b5 commit 4e31a36
Show file tree
Hide file tree
Showing 21 changed files with 3 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import {
*/
import { useBlockPreview } from '../';

jest.useRealTimers();

describe( 'useBlockPreview', () => {
beforeAll( () => {
registerBlockType( 'core/test-block', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ jest.mock( '@wordpress/data/src/components/use-dispatch', () => ( {
useDispatch: () => ( { saveEntityRecords: jest.fn() } ),
} ) );

jest.useRealTimers();

jest.mock( '@wordpress/compose', () => ( {
...jest.requireActual( '@wordpress/compose' ),
useReducedMotion: jest.fn( () => true ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import userEvent from '@testing-library/user-event';
*/
import URLPopover from '../';

jest.useRealTimers();

/**
* Returns the first found popover element up the DOM tree.
*
Expand Down
2 changes: 0 additions & 2 deletions packages/block-editor/src/utils/test/parse-css-unit-to-px.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import {
getPxFromCssUnit,
} from '../parse-css-unit-to-px';

jest.useRealTimers();

describe( 'getPxFromCssUnit', () => {
// Absolute units.
describe( 'absolute unites should return px values', () => {
Expand Down
2 changes: 0 additions & 2 deletions packages/components/src/border-control/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import {
*/
import { BorderControl } from '../';

jest.useRealTimers();

const colors = [
{ name: 'Gray', color: '#f6f7f7' },
{ name: 'Blue', color: '#72aee6' },
Expand Down
2 changes: 0 additions & 2 deletions packages/compose/src/hooks/use-disabled/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import { forwardRef } from '@wordpress/element';
*/
import useDisabled from '../';

jest.useRealTimers();

describe( 'useDisabled', () => {
const Form = forwardRef( ( { showButton }, ref ) => {
return (
Expand Down
2 changes: 0 additions & 2 deletions packages/core-data/src/locks/test/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
*/
import createLocks from '../engine';

jest.useRealTimers();

// We correctly await all promises with expect calls, but the rule doesn't detect that.
/* eslint-disable jest/valid-expect-in-promise */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import createReduxStore from '../../../redux-store';
import { createRegistry } from '../../../registry';
import { RegistryProvider } from '../../registry-provider';

jest.useRealTimers();

describe( 'useDispatch', () => {
const counterStore = {
reducer: ( state = 0, action ) => {
Expand Down
2 changes: 0 additions & 2 deletions packages/data/src/components/use-select/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import {
} from '../../..';
import useSelect from '..';

jest.useRealTimers();

describe( 'useSelect', () => {
let registry;
beforeEach( () => {
Expand Down
2 changes: 0 additions & 2 deletions packages/data/src/components/use-select/test/suspense.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import {
} from '@wordpress/data';
import { Component, Suspense } from '@wordpress/element';

jest.useRealTimers();

function createRegistryWithStore() {
const initialState = {
prefix: 'pre-',
Expand Down
2 changes: 0 additions & 2 deletions packages/data/src/components/with-dispatch/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import withDispatch from '../';
import { createRegistry } from '../../../registry';
import { RegistryProvider } from '../../registry-provider';

jest.useRealTimers();

describe( 'withDispatch', () => {
const storeOptions = {
reducer: ( state = 0, action ) => {
Expand Down
2 changes: 0 additions & 2 deletions packages/data/src/components/with-select/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import withDispatch from '../../with-dispatch';
import { createRegistry } from '../../../registry';
import { RegistryProvider } from '../../registry-provider';

jest.useRealTimers();

describe( 'withSelect', () => {
it( 'passes the relevant data to the component', () => {
const registry = createRegistry();
Expand Down
1 change: 0 additions & 1 deletion packages/data/src/redux-store/metadata/test/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
import { createRegistry } from '@wordpress/data';

jest.useRealTimers();
const testStore = {
reducer: ( state = null, action ) => {
if ( action.type === 'RECEIVE' ) {
Expand Down
2 changes: 0 additions & 2 deletions packages/data/src/redux-store/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import { createRegistry } from '../../registry';
import { createRegistryControl } from '../../factory';

jest.useRealTimers();

describe( 'controls', () => {
let registry;

Expand Down
2 changes: 0 additions & 2 deletions packages/data/src/test/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
*/
import { createRegistry, controls } from '..';

jest.useRealTimers();

describe( 'controls', () => {
// Create a registry with store to test select controls.
function createSelectTestRegistry() {
Expand Down
2 changes: 0 additions & 2 deletions packages/dependency-extraction-webpack-plugin/test/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ const webpack = require( 'webpack' );
const fixturesPath = path.join( __dirname, 'fixtures' );
const configFixtures = fs.readdirSync( fixturesPath ).sort();

jest.useRealTimers();

describe( 'DependencyExtractionWebpackPlugin', () => {
afterAll( () => rimraf( path.join( __dirname, 'build' ) ) );

Expand Down
2 changes: 0 additions & 2 deletions packages/edit-site/src/store/test/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import { store as preferencesStore } from '@wordpress/preferences';
*/
import { store as editSiteStore } from '..';

jest.useRealTimers();

const ENTITY_TYPES = {
wp_template: {
description: 'Templates to include in your theme.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import { render } from '@testing-library/react';
*/
import { AutosaveMonitor } from '../';

jest.useFakeTimers( { legacyFakeTimers: true } );
jest.useFakeTimers();
jest.spyOn( global, 'clearTimeout' );
jest.spyOn( global, 'setTimeout' );

describe( 'AutosaveMonitor', () => {
let setAutosaveTimerSpy;
Expand Down
2 changes: 0 additions & 2 deletions packages/editor/src/components/post-text-editor/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ jest.mock( '@wordpress/data/src/components/use-dispatch', () => {
};
} );

jest.useRealTimers();

describe( 'PostTextEditor', () => {
beforeEach( () => {
useSelect.mockImplementation( () => 'Hello World' );
Expand Down
2 changes: 0 additions & 2 deletions packages/editor/src/store/test/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import { store as preferencesStore } from '@wordpress/preferences';
import * as actions from '../actions';
import { store as editorStore } from '..';

jest.useRealTimers();

const postId = 44;

const postTypeConfig = {
Expand Down
2 changes: 0 additions & 2 deletions packages/readable-js-assets-webpack-plugin/test/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ const path = require( 'path' );
const rimraf = require( 'rimraf' ).sync;
const webpack = require( 'webpack' );

jest.useRealTimers();

describe( 'ReadableJsAssetsWebpackPlugin', () => {
const outputDirectory = path.join( __dirname, 'build' );
const testDirectory = path.join( __dirname, 'fixtures' );
Expand Down

0 comments on commit 4e31a36

Please sign in to comment.