mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 22:45:45 +01:00
add error notification if user deletion is unsuccessful and add DELETE_USER_SUCCESS
This commit is contained in:
@@ -23,7 +23,8 @@ import {
|
||||
DELETE_USER_SUCCESS,
|
||||
DELETE_USER_FAILURE,
|
||||
deleteUser,
|
||||
updateUserFailure
|
||||
updateUserFailure,
|
||||
deleteUserSuccess
|
||||
} from "./users";
|
||||
|
||||
import reducer from "./users";
|
||||
@@ -365,6 +366,44 @@ describe("users reducer", () => {
|
||||
expect(ford.loading).toBeFalsy();
|
||||
});
|
||||
|
||||
it("should delete deleted user in users in state if delete user action is successful", () => {
|
||||
const state = {
|
||||
users: {
|
||||
entries: [
|
||||
"zaphod",
|
||||
"ford"
|
||||
]
|
||||
}
|
||||
};
|
||||
const newState = reducer(state, deleteUserSuccess(userZaphod));
|
||||
expect(newState.users.entries).toContain("ford");
|
||||
expect(newState.users.entries).not.toContain("zaphod");
|
||||
});
|
||||
|
||||
it("should delete deleted user in usersByNames in state if delete user action is successful", () => {
|
||||
const state = {
|
||||
users: {
|
||||
entries: [
|
||||
"zaphod",
|
||||
"ford"
|
||||
]
|
||||
},
|
||||
usersByNames: {
|
||||
zaphod: {
|
||||
entry: userZaphod
|
||||
},
|
||||
ford: {
|
||||
entry: userFord
|
||||
}
|
||||
}
|
||||
};
|
||||
const newState = reducer(state, deleteUserSuccess(userZaphod));
|
||||
const ford = newState.usersByNames["ford"];
|
||||
const zaphod = newState.usersByNames["zaphod"];
|
||||
expect(zaphod).toBeUndefined();
|
||||
expect(ford.entry).toBe(userFord);
|
||||
});
|
||||
|
||||
it("should set global error state if one user could not be deleted", () => {
|
||||
const state = {
|
||||
users: {
|
||||
|
||||
Reference in New Issue
Block a user