1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { storeRedirects, handleRedirects } from './redirect-to';
7 describe('redirect-to', () => {
8 const { location } = window;
10 keepWebServiceUrl: 'http://localhost'
12 const redirectTo = '/test123';
13 const locationTemplate = {
29 afterAll((): void => {
30 window.location = location;
33 describe('storeRedirects', () => {
35 delete window.location;
38 href: `${location.href}?redirectTo=${redirectTo}`,
40 Object.defineProperty(window, 'sessionStorage', {
48 it('should store redirectTo in the session storage', () => {
53 expect(window.sessionStorage.setItem).toHaveBeenCalledWith('redirectTo', redirectTo);
57 describe('handleRedirects', () => {
59 delete window.location;
62 href: `${location.href}?redirectTo=${redirectTo}`,
64 Object.defineProperty(window, 'sessionStorage', {
66 getItem: () => redirectTo,
67 removeItem: jest.fn(),
73 it('should redirect to page when it is present in session storage', () => {
75 handleRedirects(config);
78 expect(window.location.href).toBe(`${config.keepWebServiceUrl}${redirectTo}`);