mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 06:55:47 +01:00
add error handling for fetching users
This commit is contained in:
@@ -24,7 +24,8 @@ import {
|
||||
DELETE_USER_FAILURE,
|
||||
deleteUser,
|
||||
updateUserFailure,
|
||||
deleteUserSuccess
|
||||
deleteUserSuccess,
|
||||
failedToFetchUsers
|
||||
} from "./users";
|
||||
|
||||
import reducer from "./users";
|
||||
@@ -442,6 +443,20 @@ describe("users reducer", () => {
|
||||
expect(newState.users.error).toBe(null);
|
||||
});
|
||||
|
||||
it("should set error state if users could not be fetched", () => {
|
||||
const state = {
|
||||
users: {
|
||||
error: null,
|
||||
loading: true
|
||||
}
|
||||
};
|
||||
|
||||
const error = new Error("could not edit user zaphod: ..");
|
||||
const newState = reducer(state, failedToFetchUsers('/users', error));
|
||||
expect(newState.users.error).toBe(error);
|
||||
expect(newState.users.loading).toBeFalsy();
|
||||
});
|
||||
|
||||
it("should not replace whole usersByNames map when fetching users", () => {
|
||||
const oldState = {
|
||||
usersByNames: {
|
||||
|
||||
Reference in New Issue
Block a user