2022-05-11 14:26:18 +08:00
|
|
|
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(runAllTimers: boolean = true) {
|
|
|
|
await awaitPromise();
|
|
|
|
|
|
|
|
if (runAllTimers) {
|
|
|
|
// Flush css motion state update
|
|
|
|
for (let i = 0; i < 5; i += 1) {
|
|
|
|
act(() => {
|
2023-06-07 21:59:21 +08:00
|
|
|
jest.runAllTimers();
|
2022-05-11 14:26:18 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// document.querySelectorAll('.ant-notification-fade-leave').forEach(ele => {
|
|
|
|
// fireEvent.animationEnd(ele);
|
|
|
|
// });
|
2022-11-19 13:47:33 +08:00
|
|
|
document.querySelectorAll('[role="alert"]').forEach((ele) => {
|
2023-09-13 15:19:18 +08:00
|
|
|
// close > notice > notice-wrapper
|
|
|
|
fireEvent.animationEnd(ele.parentNode?.parentNode?.parentNode!);
|
2022-05-11 14:26:18 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
await awaitPromise();
|
|
|
|
}
|