假设有一个带有一些CSS动画(例如滑入/滑出)的组件:
function MyComponent(props) {
return (
<div
className="with-animations"
onAnimationEnd={() => {
// set internal state
// logic which needs coverage
}}
>
{props.children}
</div>
);
}
我该如何验证在 onAnimationEnd
事件处理程序中的代码是否被调用?
有没有一种方法可以模拟这个过程?