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) {
|
|
|
|
await Promise.resolve();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-22 21:59:12 +08:00
|
|
|
export async function triggerMotionEnd(selector = '.ant-message-move-up-leave') {
|
2022-05-11 14:26:18 +08:00
|
|
|
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();
|
|
|
|
}
|