mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 09:46:16 +01:00
Fixed unit test
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user