16812: Added types to remove compile errors
[arvados.git] / src / common / redirect-to.test.ts
index 24eaada85183f07c09a55c07a624ebc8292c68e2..eed5b4c8e12005d168a2e07ea179ea5d58d5c3c7 100644 (file)
@@ -5,15 +5,19 @@
 import { storeRedirects, handleRedirects } from './redirect-to';
 
 describe('redirect-to', () => {
+    const { location } = window;
     const redirectTo = 'http://localhost/test123';
 
+    afterAll((): void => {
+        window.location = location;
+    });
+
     describe('storeRedirects', () => {
         beforeEach(() => {
-            Object.defineProperty(window, 'location', {
-                value: {
-                    href: `${window.location.href}?redirectTo=${redirectTo}`
-                }
-            });
+            delete window.location;
+            window.location = {
+                href: `${location.href}?redirectTo=${redirectTo}`,
+            } as any;
             Object.defineProperty(window, 'sessionStorage', {
                 value: {
                     setItem: jest.fn(),
@@ -33,11 +37,10 @@ describe('redirect-to', () => {
 
     describe('handleRedirects', () => {
         beforeEach(() => {
-            Object.defineProperty(window, 'location', {
-                value: {
-                    href: ''
-                }
-            });
+            delete window.location;
+            window.location = {
+                href: `${location.href}?redirectTo=${redirectTo}`,
+            } as any;
             Object.defineProperty(window, 'sessionStorage', {
                 value: {
                     getItem: () => redirectTo,