Files
CollabTable/shared/packages/web-ui/tests/setup.ts
T

19 lines
639 B
TypeScript
Raw Normal View History

// jsdom has no Web Animations API, which Svelte's transitions call. This stand-in finishes at once,
// so an element that leaves with a transition is removed straight away.
if (typeof Element.prototype.animate !== 'function') {
Element.prototype.animate = function animate(): Animation {
const animation = {
currentTime: 0,
onfinish: null as (() => void) | null,
cancel() {},
finish() {
animation.onfinish?.();
},
pause() {},
play() {},
finished: Promise.resolve(),
};
queueMicrotask(() => animation.onfinish?.());
return animation as unknown as Animation;
};
}