2023-06-07 21:59:21 +08:00
|
|
|
import { act, fireEvent } from '../../../tests/utils';
|
2022-05-11 14:26:18 +08:00
|
|
|
|
|
|
|
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();
|
2023-06-07 21:59:21 +08:00
|
|
|
|
|
|
|
// Flush css motion state update
|
|
|
|
for (let i = 0; i < 5; i += 1) {
|
|
|
|
act(() => {
|
|
|
|
jest.runAllTimers();
|
|
|
|
});
|
|
|
|
}
|
2022-05-11 14:26:18 +08:00
|
|
|
|
2022-11-19 13:47:33 +08:00
|
|
|
document.querySelectorAll(selector).forEach((ele) => {
|
2022-05-11 14:26:18 +08:00
|
|
|
fireEvent.animationEnd(ele);
|
|
|
|
});
|
|
|
|
|
|
|
|
await awaitPromise();
|
|
|
|
}
|