summaryrefslogtreecommitdiffstats
path: root/public/src/jestGlobalMocks.ts
diff options
context:
space:
mode:
Diffstat (limited to 'public/src/jestGlobalMocks.ts')
-rw-r--r--public/src/jestGlobalMocks.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/public/src/jestGlobalMocks.ts b/public/src/jestGlobalMocks.ts
new file mode 100644
index 0000000..e93276f
--- /dev/null
+++ b/public/src/jestGlobalMocks.ts
@@ -0,0 +1,33 @@
+global['CSS'] = null;
+
+const mock = () => {
+ let storage = {};
+ return {
+ getItem: key => (key in storage ? storage[key] : null),
+ setItem: (key, value) => (storage[key] = value || ''),
+ removeItem: key => delete storage[key],
+ clear: () => (storage = {})
+ };
+};
+
+Object.defineProperty(window, 'localStorage', { value: mock() });
+Object.defineProperty(window, 'sessionStorage', { value: mock() });
+Object.defineProperty(document, 'doctype', {
+ value: '<!DOCTYPE html>'
+});
+Object.defineProperty(window, 'getComputedStyle', {
+ value: () => {
+ return {
+ display: 'none',
+ appearance: ['-webkit-appearance']
+ };
+ }
+});
+Object.defineProperty(document.body.style, 'transform', {
+ value: () => {
+ return {
+ enumerable: true,
+ configurable: true
+ };
+ }
+});