@ryusei/code
Version:
<div align="center"> <a href="https://code.ryuseijs.com"> <img alt="RyuseiCode" src="https://code.ryuseijs.com/images/svg/logo.svg" width="70"> </a>
31 lines (26 loc) • 753 B
text/typescript
/**
* jsdom does not have the URL.createObjectURL implementation.
*/
URL.createObjectURL = jest.fn();
/**
* Returns an empty DOMRect object.
*/
Range.prototype.getBoundingClientRect = () => {
return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0, x: 0, y: 0, toJSON: jest.fn() };
};
/**
* jsdom does not have the `PointerEvent`.
*/
Object.defineProperty( window, 'PointerEvent', { value: Event } );
/**
* jsdom does not have the `window.scrollTo()`.
*/
Object.defineProperty( window, 'scrollTo', { value: jest.fn(), writable: true } );
/**
* Mocks the Canvas context object.
*/
HTMLCanvasElement.prototype.getContext = () => {
return {
measureText: () => ( { width: 0 } ),
} as any;
};