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
|
// @flow
|
||||||
import {contextPath} from "./urls";
|
import {contextPath} from "./urls";
|
||||||
|
|
||||||
export const NOT_FOUND_ERROR = Error("not found");
|
export const NOT_FOUND_ERROR_MESSAGE = "not found";
|
||||||
export const UNAUTHORIZED_ERROR = Error("unauthorized");
|
export const UNAUTHORIZED_ERROR_MESSAGE = "unauthorized";
|
||||||
|
|
||||||
const fetchOptions: RequestOptions = {
|
const fetchOptions: RequestOptions = {
|
||||||
credentials: "same-origin",
|
credentials: "same-origin",
|
||||||
@@ -15,9 +15,9 @@ function handleStatusCode(response: Response) {
|
|||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
switch (response.status) {
|
switch (response.status) {
|
||||||
case 401:
|
case 401:
|
||||||
return throwErrorWithMessage(response, UNAUTHORIZED_ERROR.message);
|
return throwErrorWithMessage(response, UNAUTHORIZED_ERROR_MESSAGE);
|
||||||
case 404:
|
case 404:
|
||||||
return throwErrorWithMessage(response, NOT_FOUND_ERROR.message);
|
return throwErrorWithMessage(response, NOT_FOUND_ERROR_MESSAGE);
|
||||||
default:
|
default:
|
||||||
return throwErrorWithMessage(response, "server returned status code " + response.status);
|
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 { default as Tooltip } from "./Tooltip";
|
||||||
export { getPageFromMatch } from "./urls";
|
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 "./buttons";
|
||||||
export * from "./config";
|
export * from "./config";
|
||||||
|
|||||||
@@ -2,7 +2,10 @@
|
|||||||
import type { Me } from "@scm-manager/ui-types";
|
import type { Me } from "@scm-manager/ui-types";
|
||||||
import * as types from "./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 { isPending } from "./pending";
|
||||||
import { getFailure } from "./failure";
|
import { getFailure } from "./failure";
|
||||||
import {
|
import {
|
||||||
@@ -187,7 +190,7 @@ export const fetchMe = (link: string) => {
|
|||||||
dispatch(fetchMeSuccess(me));
|
dispatch(fetchMeSuccess(me));
|
||||||
})
|
})
|
||||||
.catch((error: Error) => {
|
.catch((error: Error) => {
|
||||||
if (error === UNAUTHORIZED_ERROR) {
|
if (error.message === UNAUTHORIZED_ERROR_MESSAGE) {
|
||||||
dispatch(fetchMeUnauthenticated());
|
dispatch(fetchMeUnauthenticated());
|
||||||
} else {
|
} else {
|
||||||
dispatch(fetchMeFailure(error));
|
dispatch(fetchMeFailure(error));
|
||||||
|
|||||||
Reference in New Issue
Block a user