From b4c313862e116819b00628831b5d5b6888c6fae4 Mon Sep 17 00:00:00 2001 From: philipp Date: Wed, 21 Nov 2018 11:12:47 +0100 Subject: [PATCH] Fixed unit test --- scm-ui-components/packages/ui-components/src/apiclient.js | 8 ++++---- scm-ui-components/packages/ui-components/src/index.js | 2 +- scm-ui/src/modules/auth.js | 7 +++++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/scm-ui-components/packages/ui-components/src/apiclient.js b/scm-ui-components/packages/ui-components/src/apiclient.js index f51b96de43..3fd90a2d7a 100644 --- a/scm-ui-components/packages/ui-components/src/apiclient.js +++ b/scm-ui-components/packages/ui-components/src/apiclient.js @@ -1,8 +1,8 @@ // @flow import {contextPath} from "./urls"; -export const NOT_FOUND_ERROR = Error("not found"); -export const UNAUTHORIZED_ERROR = Error("unauthorized"); +export const NOT_FOUND_ERROR_MESSAGE = "not found"; +export const UNAUTHORIZED_ERROR_MESSAGE = "unauthorized"; const fetchOptions: RequestOptions = { credentials: "same-origin", @@ -15,9 +15,9 @@ function handleStatusCode(response: Response) { if (!response.ok) { switch (response.status) { case 401: - return throwErrorWithMessage(response, UNAUTHORIZED_ERROR.message); + return throwErrorWithMessage(response, UNAUTHORIZED_ERROR_MESSAGE); case 404: - return throwErrorWithMessage(response, NOT_FOUND_ERROR.message); + return throwErrorWithMessage(response, NOT_FOUND_ERROR_MESSAGE); default: return throwErrorWithMessage(response, "server returned status code " + response.status); } diff --git a/scm-ui-components/packages/ui-components/src/index.js b/scm-ui-components/packages/ui-components/src/index.js index 41e385af8d..521aab09fe 100644 --- a/scm-ui-components/packages/ui-components/src/index.js +++ b/scm-ui-components/packages/ui-components/src/index.js @@ -22,7 +22,7 @@ export { default as HelpIcon } from "./HelpIcon"; export { default as Tooltip } from "./Tooltip"; export { getPageFromMatch } from "./urls"; -export { apiClient, NOT_FOUND_ERROR, UNAUTHORIZED_ERROR } from "./apiclient.js"; +export { apiClient, NOT_FOUND_ERROR_MESSAGE, UNAUTHORIZED_ERROR_MESSAGE } from "./apiclient.js"; export * from "./buttons"; export * from "./config"; diff --git a/scm-ui/src/modules/auth.js b/scm-ui/src/modules/auth.js index e9bccb8fbc..489f701a74 100644 --- a/scm-ui/src/modules/auth.js +++ b/scm-ui/src/modules/auth.js @@ -2,7 +2,10 @@ import type { Me } from "@scm-manager/ui-types"; import * as types from "./types"; -import { apiClient, UNAUTHORIZED_ERROR } from "@scm-manager/ui-components"; +import { + apiClient, + UNAUTHORIZED_ERROR_MESSAGE +} from "@scm-manager/ui-components"; import { isPending } from "./pending"; import { getFailure } from "./failure"; import { @@ -187,7 +190,7 @@ export const fetchMe = (link: string) => { dispatch(fetchMeSuccess(me)); }) .catch((error: Error) => { - if (error === UNAUTHORIZED_ERROR) { + if (error.message === UNAUTHORIZED_ERROR_MESSAGE) { dispatch(fetchMeUnauthenticated()); } else { dispatch(fetchMeFailure(error));