projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'main' into 15397-remove-obsolete-apis
[arvados.git]
/
services
/
workbench2
/
src
/
common
/
redirect-to.test.ts
diff --git
a/services/workbench2/src/common/redirect-to.test.ts
b/services/workbench2/src/common/redirect-to.test.ts
index adb52f4b0ce494167170c02390433a4ba82dec9f..1e7bf3a100a91c94fa36657785645288e1b49d91 100644
(file)
--- a/
services/workbench2/src/common/redirect-to.test.ts
+++ b/
services/workbench2/src/common/redirect-to.test.ts
@@
-5,7
+5,9
@@
import { storeRedirects, handleRedirects } from './redirect-to';
describe('redirect-to', () => {
import { storeRedirects, handleRedirects } from './redirect-to';
describe('redirect-to', () => {
- const { location } = window;
+ const mockWindow: { location?: any, localStorage?: any} = window
+
+ const { location } = mockWindow;
const config: any = {
keepWebServiceUrl: 'http://localhost',
keepWebServiceInlineUrl: 'http://localhost-inline'
const config: any = {
keepWebServiceUrl: 'http://localhost',
keepWebServiceInlineUrl: 'http://localhost-inline'
@@
-28,17
+30,17
@@
describe('redirect-to', () => {
};
afterAll((): void => {
};
afterAll((): void => {
-
w
indow.location = location;
+
mockW
indow.location = location;
});
describe('storeRedirects', () => {
beforeEach(() => {
});
describe('storeRedirects', () => {
beforeEach(() => {
- delete
w
indow.location;
-
w
indow.location = {
+ delete
mockW
indow.location;
+
mockW
indow.location = {
...locationTemplate,
href: `${location.href}?redirectToDownload=${redirectTo}`,
} as any;
...locationTemplate,
href: `${location.href}?redirectToDownload=${redirectTo}`,
} as any;
- Object.defineProperty(
w
indow, 'localStorage', {
+ Object.defineProperty(
mockW
indow, 'localStorage', {
value: {
setItem: jest.fn(),
},
value: {
setItem: jest.fn(),
},
@@
-51,18
+53,18
@@
describe('redirect-to', () => {
storeRedirects();
// then
storeRedirects();
// then
- expect(
w
indow.localStorage.setItem).toHaveBeenCalledWith('redirectToDownload', decodeURIComponent(redirectTo));
+ expect(
mockW
indow.localStorage.setItem).toHaveBeenCalledWith('redirectToDownload', decodeURIComponent(redirectTo));
});
});
describe('handleRedirects', () => {
beforeEach(() => {
});
});
describe('handleRedirects', () => {
beforeEach(() => {
- delete
w
indow.location;
-
w
indow.location = {
+ delete
mockW
indow.location;
+
mockW
indow.location = {
...locationTemplate,
href: `${location.href}?redirectToDownload=${redirectTo}`,
} as any;;
...locationTemplate,
href: `${location.href}?redirectToDownload=${redirectTo}`,
} as any;;
- Object.defineProperty(
w
indow, 'localStorage', {
+ Object.defineProperty(
mockW
indow, 'localStorage', {
value: {
getItem: () => redirectTo,
removeItem: jest.fn(),
value: {
getItem: () => redirectTo,
removeItem: jest.fn(),
@@
-76,7
+78,7
@@
describe('redirect-to', () => {
handleRedirects("abcxyz", config);
// then
handleRedirects("abcxyz", config);
// then
- expect(
w
indow.location.href).toBe(`${config.keepWebServiceUrl}${redirectTo}?api_token=abcxyz`);
+ expect(
mockW
indow.location.href).toBe(`${config.keepWebServiceUrl}${redirectTo}?api_token=abcxyz`);
});
});
});
});
});
});