From 2e31a473f22dcea24eaa2e1dbf1b7078647548e1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Kuty=C5=82a?= Date: Tue, 29 Sep 2020 22:47:12 +0200 Subject: [PATCH] 16812: Added proper location template MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła --- src/common/redirect-to.test.ts | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/common/redirect-to.test.ts b/src/common/redirect-to.test.ts index eed5b4c8..d1426c29 100644 --- a/src/common/redirect-to.test.ts +++ b/src/common/redirect-to.test.ts @@ -7,6 +7,21 @@ import { storeRedirects, handleRedirects } from './redirect-to'; 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; @@ -16,8 +31,9 @@ describe('redirect-to', () => { beforeEach(() => { delete window.location; window.location = { + ...locationTemplate, href: `${location.href}?redirectTo=${redirectTo}`, - } as any; + }; Object.defineProperty(window, 'sessionStorage', { value: { setItem: jest.fn(), @@ -39,8 +55,9 @@ describe('redirect-to', () => { beforeEach(() => { delete window.location; window.location = { + ...locationTemplate, href: `${location.href}?redirectTo=${redirectTo}`, - } as any; + }; Object.defineProperty(window, 'sessionStorage', { value: { getItem: () => redirectTo, -- 2.30.2