| 
									
										
										
										
											2022-01-07 15:58:30 +01:00
										 |  |  | // @ts-nocheck
 | 
					
						
							| 
									
										
										
										
											2019-09-13 13:49:11 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | globalThis.isBrowser = typeof window !== "undefined" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ;(async function () { | 
					
						
							|  |  |  | 	const noOp = () => {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (isBrowser) { | 
					
						
							|  |  |  | 		/** | 
					
						
							|  |  |  | 		 * runs this test exclusively on browsers (not nodec) | 
					
						
							|  |  |  | 		 */ | 
					
						
							|  |  |  | 		window.browser = (func) => func | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/** | 
					
						
							|  |  |  | 		 * runs this test exclusively on node (not browsers) | 
					
						
							|  |  |  | 		 */ | 
					
						
							|  |  |  | 		window.node = () => noOp | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/** | 
					
						
							|  |  |  | 		 * runs this test exclusively on browsers (not node) | 
					
						
							|  |  |  | 		 */ | 
					
						
							|  |  |  | 		globalThis.browser = () => noOp | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/** | 
					
						
							|  |  |  | 		 * runs this test exclusively on node (not browsers) | 
					
						
							|  |  |  | 		 */ | 
					
						
							|  |  |  | 		globalThis.node = (func) => func | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-09 18:41:10 +02:00
										 |  |  | 		const browserMock = await import("mithril/test-utils/browserMock.js") | 
					
						
							| 
									
										
										
										
											2019-09-13 13:49:11 +02:00
										 |  |  | 		globalThis.window = browserMock.default() | 
					
						
							|  |  |  | 		globalThis.window.getElementsByTagName = function () { | 
					
						
							|  |  |  | 		} // for styles.js
 | 
					
						
							|  |  |  | 		globalThis.window.location = {hostname: "https://tutanota.com"} | 
					
						
							|  |  |  | 		globalThis.window.document.addEventListener = function () { | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		globalThis.document = globalThis.window.document | 
					
						
							|  |  |  | 		globalThis.navigator = globalThis.window.navigator | 
					
						
							|  |  |  | 		const local = {} | 
					
						
							|  |  |  | 		globalThis.localStorage = { | 
					
						
							|  |  |  | 			getItem: key => local[key], | 
					
						
							|  |  |  | 			setItem: (key, value) => local[key] = value | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		globalThis.requestAnimationFrame = globalThis.requestAnimationFrame || (callback => setTimeout(callback, 10)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		globalThis.btoa = str => Buffer.from(str, 'binary').toString('base64') | 
					
						
							|  |  |  | 		globalThis.atob = b64Encoded => Buffer.from(b64Encoded, 'base64').toString('binary') | 
					
						
							|  |  |  | 		globalThis.WebSocket = noOp | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		const nowOffset = Date.now(); | 
					
						
							|  |  |  | 		globalThis.performance = { | 
					
						
							|  |  |  | 			now: function () { | 
					
						
							|  |  |  | 				return Date.now() - nowOffset; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		globalThis.performance = { | 
					
						
							|  |  |  | 			now: Date.now, | 
					
						
							|  |  |  | 			mark: noOp, | 
					
						
							|  |  |  | 			measure: noOp, | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		const crypto = await import("crypto") | 
					
						
							|  |  |  | 		globalThis.crypto = { | 
					
						
							|  |  |  | 			getRandomValues: function (bytes) { | 
					
						
							|  |  |  | 				let randomBytes = crypto.randomBytes(bytes.length) | 
					
						
							|  |  |  | 				bytes.set(randomBytes) | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		window.tutao = { | 
					
						
							|  |  |  | 			appState: { | 
					
						
							|  |  |  | 				prefixWithoutFile: "./" | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		globalThis.XMLHttpRequest = (await import("xhr2")).default | 
					
						
							|  |  |  | 		globalThis.express = (await import("express")).default | 
					
						
							|  |  |  | 		globalThis.bodyParser = (await import("body-parser")).default | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-04 14:05:23 +01:00
										 |  |  | 	const Env = await import("../../src/api/common/Env") | 
					
						
							| 
									
										
										
										
											2019-09-13 13:49:11 +02:00
										 |  |  | 	Env.bootFinished() | 
					
						
							|  |  |  | 	import('./Suite.js') | 
					
						
							|  |  |  | })() | 
					
						
							|  |  |  | 
 |