Skip to content

Commit

Permalink
[core] Improve sleep test helper
Browse files Browse the repository at this point in the history
The helper was duplicated. I have also added the explict return type
so TypeScript can import the type of the helper faster.
  • Loading branch information
oliviertassinari committed Sep 16, 2023
1 parent 946cf78 commit bed7af3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@ import * as React from 'react';
import { spy } from 'sinon';
import { expect } from 'chai';
import { createRenderer } from '@mui/monorepo/test/utils';
import { sleep } from 'test/utils/helperFn';
import { createUseGridApiEventHandler } from './useGridApiEventHandler';
import { FinalizationRegistryBasedCleanupTracking } from '../../utils/cleanupTracking/FinalizationRegistryBasedCleanupTracking';
import { TimerBasedCleanupTracking } from '../../utils/cleanupTracking/TimerBasedCleanupTracking';

const noop = spy();

function sleep(time: number): Promise<void> {
return new Promise<void>((res) => {
setTimeout(res, time);
});
}

describe('useGridApiEventHandler', () => {
const { render } = createRenderer();

Expand Down
2 changes: 1 addition & 1 deletion test/utils/helperFn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { act } from '@mui/monorepo/test/utils';
import { unwrapPrivateAPI } from '@mui/x-data-grid/internals';
import type { GridApiCommon } from '@mui/x-data-grid/models/api/gridApiCommon';

export function sleep(duration: number) {
export function sleep(duration: number): Promise<void> {
return new Promise<void>((resolve) => {
setTimeout(() => {
resolve();
Expand Down

0 comments on commit bed7af3

Please sign in to comment.