16812: Added proper location template
authorDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Tue, 29 Sep 2020 20:47:12 +0000 (22:47 +0200)
committerDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Tue, 29 Sep 2020 20:47:12 +0000 (22:47 +0200)
Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla@contractors.roche.com>

src/common/redirect-to.test.ts

index eed5b4c8e12005d168a2e07ea179ea5d58d5c3c7..d1426c2916b75bc62c2eb3c4c3f11683fe3effe1 100644 (file)
@@ -7,6 +7,21 @@ import { storeRedirects, handleRedirects } from './redirect-to';
 describe('redirect-to', () => {
     const { location } = window;
     const redirectTo = 'http://localhost/test123';
 describe('redirect-to', () => {
     const { location } = window;
     const redirectTo = 'http://localhost/test123';
+    const locationTemplate = {
+        hash: '',
+        hostname: '',
+        origin: '',
+        host: '',
+        pathname: '',
+        port: '80',
+        protocol: 'http',
+        search: '',
+        reload: () => {},
+        replace: () => {},
+        assign: () => {},
+        ancestorOrigins: new DOMStringList(),
+        href: '',
+    };
 
     afterAll((): void => {
         window.location = location;
 
     afterAll((): void => {
         window.location = location;
@@ -16,8 +31,9 @@ describe('redirect-to', () => {
         beforeEach(() => {
             delete window.location;
             window.location = {
         beforeEach(() => {
             delete window.location;
             window.location = {
+                ...locationTemplate,
                 href: `${location.href}?redirectTo=${redirectTo}`,
                 href: `${location.href}?redirectTo=${redirectTo}`,
-            } as any;
+            };
             Object.defineProperty(window, 'sessionStorage', {
                 value: {
                     setItem: jest.fn(),
             Object.defineProperty(window, 'sessionStorage', {
                 value: {
                     setItem: jest.fn(),
@@ -39,8 +55,9 @@ describe('redirect-to', () => {
         beforeEach(() => {
             delete window.location;
             window.location = {
         beforeEach(() => {
             delete window.location;
             window.location = {
+                ...locationTemplate,
                 href: `${location.href}?redirectTo=${redirectTo}`,
                 href: `${location.href}?redirectTo=${redirectTo}`,
-            } as any;
+            };
             Object.defineProperty(window, 'sessionStorage', {
                 value: {
                     getItem: () => redirectTo,
             Object.defineProperty(window, 'sessionStorage', {
                 value: {
                     getItem: () => redirectTo,