Skip to content

Commit

Permalink
Fix redirect test
Browse files Browse the repository at this point in the history
  • Loading branch information
geido committed Feb 14, 2022
1 parent 7cedae9 commit c5133cb
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -501,11 +501,16 @@ describe('SupersetClientClass', () => {

it('should redirect Unauthorized', async () => {
const mockRequestUrl = 'https://host/get/url';
const mockRequestPath = '/get/url';
const mockRequestSearch = '?param=1&param=2';
const { location } = window;
// @ts-ignore
delete window.location;
// @ts-ignore
window.location = { href: mockRequestUrl };
window.location = {
pathname: mockRequestPath,
search: mockRequestSearch,
};
const authSpy = jest
.spyOn(SupersetClientClass.prototype, 'ensureAuth')
.mockImplementation();
Expand All @@ -523,7 +528,9 @@ describe('SupersetClientClass', () => {
error = err;
} finally {
const redirectURL = window.location.href;
expect(redirectURL).toBe(`/login?next=${mockRequestUrl}`);
expect(redirectURL).toBe(
`/login?next=${mockRequestPath + mockRequestSearch}`,
);
expect(error.status).toBe(401);
}

Expand Down

0 comments on commit c5133cb

Please sign in to comment.