test: Update page-header test case (#38286)

This commit is contained in:
hms181231 2022-10-31 10:20:29 +08:00 committed by GitHub
parent e939b43af4
commit 37fb68ab68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,5 @@
import React from 'react';
import { act, fireEvent, render, sleep, triggerResize } from '../../../tests/utils';
import { fireEvent, render, waitFakeTimer, triggerResize } from '../../../tests/utils';
import PageHeader from '..';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
@ -121,10 +121,7 @@ describe('PageHeader', () => {
jest.useFakeTimers();
const { container } = render(<PageHeader title="Page Title" extra="extra" />);
triggerResize(container.firstChild as HTMLDivElement);
await act(async () => {
await jest.runAllTimers();
await sleep();
});
await waitFakeTimer();
expect(container.querySelector('div.ant-page-header')).toHaveClass('ant-page-header-compact');
jest.useRealTimers();
});