mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 06:55:47 +01:00
fixed reducer for FETCH_USER_SUCCESS
This commit is contained in:
@@ -35,7 +35,8 @@ import {
|
||||
deleteUserSuccess,
|
||||
fetchUsersPending,
|
||||
fetchUserPending,
|
||||
fetchUserFailure
|
||||
fetchUserFailure,
|
||||
fetchUserSuccess
|
||||
} from "./users";
|
||||
|
||||
import reducer from "./users";
|
||||
@@ -443,11 +444,44 @@ describe("users reducer", () => {
|
||||
expect(newState.usersByNames["zaphod"].loading).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should not affect users state", () => {
|
||||
const newState = reducer(
|
||||
{
|
||||
users: {
|
||||
entries: ["ford"]
|
||||
}
|
||||
},
|
||||
fetchUserPending("zaphod")
|
||||
);
|
||||
expect(newState.usersByNames["zaphod"].loading).toBeTruthy();
|
||||
expect(newState.users.entries).toEqual(["ford"]);
|
||||
});
|
||||
|
||||
it("should update state according to FETCH_USER_FAILURE action", () => {
|
||||
const newState = reducer(
|
||||
{},
|
||||
fetchUserFailure(userFord.name, new Error("kaputt!"))
|
||||
);
|
||||
expect(newState.usersByNames["ford"].error).toBeTruthy;
|
||||
expect(newState.usersByNames["ford"].error).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should update state according to FETCH_USER_SUCCESS action", () => {
|
||||
const newState = reducer({}, fetchUserSuccess(userFord));
|
||||
expect(newState.usersByNames["ford"].loading).toBeFalsy();
|
||||
expect(newState.usersByNames["ford"].entry).toBe(userFord);
|
||||
});
|
||||
|
||||
it("should affect users state nor the state of other users", () => {
|
||||
const newState = reducer(
|
||||
{
|
||||
users: {
|
||||
entries: ["zaphod"]
|
||||
}
|
||||
},
|
||||
fetchUserSuccess(userFord)
|
||||
);
|
||||
expect(newState.usersByNames["ford"].loading).toBeFalsy();
|
||||
expect(newState.usersByNames["ford"].entry).toBe(userFord);
|
||||
expect(newState.users.entries).toEqual(["zaphod"]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user