mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 22:45:45 +01:00
Added unit tests
This commit is contained in:
@@ -11,6 +11,10 @@ import {
|
||||
FETCH_USERS_SUCCESS,
|
||||
fetchUsers,
|
||||
FETCH_USERS_FAILURE,
|
||||
addUser,
|
||||
ADD_USER,
|
||||
ADD_USER_SUCCESS,
|
||||
ADD_USER_FAILURE,
|
||||
updateUser,
|
||||
UPDATE_USER,
|
||||
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", () => {
|
||||
fetchMock.putOnce("http://localhost:8081/scm/api/rest/v2/users/zaphod", {
|
||||
status: 204
|
||||
|
||||
Reference in New Issue
Block a user