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