Newer
Older
gnexus-ui-kit / tests / setup.js
@Eugene Sukhodolskiy Eugene Sukhodolskiy 1 day ago 583 bytes Add Vue adapter behavior contract tests
// jsdom (without pretendToBeVisual) has no requestAnimationFrame, but the
// overlay components rely on it for the a-hide -> a-show transition cycle.
if(!globalThis.requestAnimationFrame) {
	globalThis.requestAnimationFrame = callback => setTimeout(() => callback(performance.now()), 0);
	globalThis.cancelAnimationFrame = clearTimeout;
}

// jsdom has no layout engine, so scrolling is a no-op.
if(!Element.prototype.scrollIntoView) {
	Element.prototype.scrollIntoView = () => {};
}

export function raf() {
	return new Promise(resolve => requestAnimationFrame(() => resolve()));
}