ant-design/components/message/__tests__/util.ts
renovate[bot] 863f61d908
chore(deps): update dependency eslint to v9 (#50690)
Co-authored-by: afc163 <afc163@gmail.com>
2024-09-19 03:30:19 +08:00

25 lines
523 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(selector = '.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();
}