mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 23:45:44 +01:00
Added unit tests
This commit is contained in:
@@ -170,7 +170,7 @@ function deleteUserFailure(url: string, err: Error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function deleteUser(link: string) {
|
export function deleteUser(link: string) {
|
||||||
return function(dispatch: ThunkDispatch) {
|
return function(dispatch: Dispatch) {
|
||||||
dispatch(requestDeleteUser(link));
|
dispatch(requestDeleteUser(link));
|
||||||
return apiClient
|
return apiClient
|
||||||
.delete(link)
|
.delete(link)
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ import {
|
|||||||
FETCH_USERS_SUCCESS,
|
FETCH_USERS_SUCCESS,
|
||||||
fetchUsers,
|
fetchUsers,
|
||||||
FETCH_USERS_FAILURE,
|
FETCH_USERS_FAILURE,
|
||||||
|
addUser,
|
||||||
|
ADD_USER,
|
||||||
|
ADD_USER_SUCCESS,
|
||||||
|
ADD_USER_FAILURE,
|
||||||
updateUser,
|
updateUser,
|
||||||
UPDATE_USER,
|
UPDATE_USER,
|
||||||
UPDATE_USER_FAILURE,
|
UPDATE_USER_FAILURE,
|
||||||
@@ -158,6 +162,33 @@ describe("fetch tests", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("successful user add", () => {
|
||||||
|
fetchMock.postOnce("/scm/api/rest/v2/users", {
|
||||||
|
status: 204
|
||||||
|
});
|
||||||
|
|
||||||
|
const store = mockStore({});
|
||||||
|
return store.dispatch(addUser(userZaphod)).then(() => {
|
||||||
|
const actions = store.getActions();
|
||||||
|
expect(actions[0].type).toEqual(ADD_USER);
|
||||||
|
expect(actions[1].type).toEqual(ADD_USER_SUCCESS);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test("user add failed", () => {
|
||||||
|
fetchMock.postOnce("/scm/api/rest/v2/users", {
|
||||||
|
status: 500
|
||||||
|
});
|
||||||
|
|
||||||
|
const store = mockStore({});
|
||||||
|
return store.dispatch(addUser(userZaphod)).then(() => {
|
||||||
|
const actions = store.getActions();
|
||||||
|
expect(actions[0].type).toEqual(ADD_USER);
|
||||||
|
expect(actions[1].type).toEqual(ADD_USER_FAILURE);
|
||||||
|
expect(actions[1].payload).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test("successful user update", () => {
|
test("successful user update", () => {
|
||||||
fetchMock.putOnce("http://localhost:8081/scm/api/rest/v2/users/zaphod", {
|
fetchMock.putOnce("http://localhost:8081/scm/api/rest/v2/users/zaphod", {
|
||||||
status: 204
|
status: 204
|
||||||
|
|||||||
Reference in New Issue
Block a user