From: Daniel Kutyła Date: Mon, 28 Sep 2020 15:31:27 +0000 (+0200) Subject: 16812: Another way of testing href X-Git-Tag: 2.1.1~9^2~11 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/cde4f5bcb537f69e6b0bc2349cbd0f27944a6f65 16812: Another way of testing href Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła --- 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,