forked from HSF/phoenix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest-global-mocks.ts
45 lines (38 loc) · 1.08 KB
/
jest-global-mocks.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { jest } from '@jest/globals';
import { TextDecoder } from 'util';
Object.defineProperty(window, 'CSS', { value: null });
Object.defineProperty(document, 'doctype', {
value: '<!DOCTYPE html>',
});
Object.defineProperty(window, 'getComputedStyle', {
value: () => {
return {
display: 'none',
appearance: ['-webkit-appearance'],
};
},
});
Object.defineProperty(window, 'getComputedStyle', {
value: () => ({
getPropertyValue: (_prop) => {
return '';
},
}),
});
/**
* ISSUE: https://github.com/angular/material2/issues/7101
* Workaround for JSDOM missing transform property
*/
Object.defineProperty(document.body.style, 'transform', {
value: () => {
return {
enumerable: true,
configurable: true,
};
},
});
HTMLCanvasElement.prototype.getContext = <
typeof HTMLCanvasElement.prototype.getContext
>jest.fn();
// For being able to mock FileList in `packages/phoenix-ng/projects/phoenix-ui-components/lib/components/ui-menu\io-options\io-options-dialog/io-options-dialog.component.test.ts:10`.
globalThis.TextDecoder = TextDecoder;