mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-04 13:08:41 +08:00
863f61d908
Co-authored-by: afc163 <afc163@gmail.com>
31 lines
749 B
TypeScript
31 lines
749 B
TypeScript
import { act, fireEvent } from '../../../tests/utils';
|
|
|
|
export async function awaitPromise() {
|
|
for (let i = 0; i < 10; i += 1) {
|
|
await Promise.resolve();
|
|
}
|
|
}
|
|
|
|
export async function triggerMotionEnd(runAllTimers = true) {
|
|
await awaitPromise();
|
|
|
|
if (runAllTimers) {
|
|
// Flush css motion state update
|
|
for (let i = 0; i < 5; i += 1) {
|
|
act(() => {
|
|
jest.runAllTimers();
|
|
});
|
|
}
|
|
}
|
|
|
|
// document.querySelectorAll('.ant-notification-fade-leave').forEach(ele => {
|
|
// fireEvent.animationEnd(ele);
|
|
// });
|
|
document.querySelectorAll('[role="alert"]').forEach((ele) => {
|
|
// close > notice > notice-wrapper
|
|
fireEvent.animationEnd(ele.parentNode?.parentNode?.parentNode!);
|
|
});
|
|
|
|
await awaitPromise();
|
|
}
|