Skip to content

Commit

Permalink
[test-utils] Fix flushMicrotasks, export types (#42771)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaldudak committed Jun 27, 2024
1 parent 0656e39 commit 2448fd9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
6 changes: 3 additions & 3 deletions packages-internal/test-utils/src/createRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ function renderToString(
};
}

interface Clock {
export interface Clock {
/**
* Runs all timers until there are no more remaining.
* WARNING: This may cause an infinite loop if a timeout constantly schedules another timeout.
Expand Down Expand Up @@ -363,7 +363,7 @@ interface Clock {
restore(): void;
}

type ClockConfig = undefined | number | Date;
export type ClockConfig = undefined | number | Date;

function createClock(defaultMode: 'fake' | 'real', config: ClockConfig): Clock {
let clock: ReturnType<typeof useFakeTimers> | null = null;
Expand Down Expand Up @@ -436,7 +436,7 @@ function createClock(defaultMode: 'fake' | 'real', config: ClockConfig): Clock {
};
}

interface Renderer {
export interface Renderer {
clock: Clock;
render(element: React.ReactElement<any>, options?: RenderOptions): MuiRenderResult;
renderToString(
Expand Down
2 changes: 1 addition & 1 deletion packages-internal/test-utils/src/flushMicrotasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { act } from './createRenderer';
export default async function flushMicrotasks() {
if (/jsdom/.test(window.navigator.userAgent)) {
// This is only needed for JSDOM and causes issues in real browsers
await act(() => async () => {});
await act(async () => {});
}
}
1 change: 1 addition & 0 deletions packages-internal/test-utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"lib": ["es2020", "dom"],
"noEmit": true,
"moduleResolution": "node",
"types": ["node"],
Expand Down
12 changes: 6 additions & 6 deletions packages/mui-base/src/Select/Select.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -998,8 +998,8 @@ describe('<Select />', () => {
expect(screen.getByRole('combobox')).to.have.attribute('aria-expanded', 'false');
});

it('should have the aria-expanded attribute set to true when the listbox is open', () => {
render(
it('should have the aria-expanded attribute set to true when the listbox is open', async () => {
await render(
<Select>
<Option value={1}>One</Option>
</Select>,
Expand All @@ -1013,8 +1013,8 @@ describe('<Select />', () => {
expect(select).to.have.attribute('aria-expanded', 'true');
});

it('should have the aria-controls attribute', () => {
render(
it('should have the aria-controls attribute', async () => {
await render(
<Select>
<Option value={1}>One</Option>
</Select>,
Expand All @@ -1033,8 +1033,8 @@ describe('<Select />', () => {
expect(select).to.have.attribute('aria-controls', listboxId!);
});

it('should have the correct tabindex attribute', () => {
render(
it('should have the correct tabindex attribute', async () => {
await render(
<Select>
<Option value={1}>One</Option>
</Select>,
Expand Down

0 comments on commit 2448fd9

Please sign in to comment.