From cde4f5bcb537f69e6b0bc2349cbd0f27944a6f65 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Kuty=C5=82a?= Date: Mon, 28 Sep 2020 17:31:27 +0200 Subject: [PATCH] 16812: Another way of testing href 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 | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/common/redirect-to.test.ts b/src/common/redirect-to.test.ts index 94000a98..3dad8233 100644 --- a/src/common/redirect-to.test.ts +++ b/src/common/redirect-to.test.ts @@ -5,16 +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}` - }, - writable: true - }); + delete window.location; + window.location = { + href: `${location.href}?redirectTo=${redirectTo}`, + }; Object.defineProperty(window, 'sessionStorage', { value: { setItem: jest.fn(), @@ -34,12 +37,10 @@ describe('redirect-to', () => { describe('handleRedirects', () => { beforeEach(() => { - Object.defineProperty(window, 'location', { - value: { - href: '' - }, - writable: true - }); + delete window.location; + window.location = { + href: `${location.href}?redirectTo=${redirectTo}`, + }; Object.defineProperty(window, 'sessionStorage', { value: { getItem: () => redirectTo, -- 2.30.2