mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-14 17:01:17 +08:00
7322aa6f5f
This reverts commit 6759887c44
.
26 lines
580 B
TypeScript
26 lines
580 B
TypeScript
import { act, fireEvent } from '../../../tests/utils';
|
|
|
|
export async function awaitPromise() {
|
|
for (let i = 0; i < 10; i += 1) {
|
|
// eslint-disable-next-line no-await-in-loop
|
|
await Promise.resolve();
|
|
}
|
|
}
|
|
|
|
export async function triggerMotionEnd(selector: string = '.ant-message-move-up-leave') {
|
|
await awaitPromise();
|
|
|
|
// Flush css motion state update
|
|
for (let i = 0; i < 5; i += 1) {
|
|
act(() => {
|
|
jest.runAllTimers();
|
|
});
|
|
}
|
|
|
|
document.querySelectorAll(selector).forEach((ele) => {
|
|
fireEvent.animationEnd(ele);
|
|
});
|
|
|
|
await awaitPromise();
|
|
}
|