mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 23:45:44 +01:00
added config modify
This commit is contained in:
@@ -8,10 +8,14 @@ import reducer, {
|
||||
FETCH_CONFIG_PENDING,
|
||||
FETCH_CONFIG_SUCCESS,
|
||||
FETCH_CONFIG_FAILURE,
|
||||
MODIFY_CONFIG_PENDING,
|
||||
MODIFY_CONFIG_SUCCESS,
|
||||
MODIFY_CONFIG_FAILURE,
|
||||
fetchConfig,
|
||||
fetchConfigSuccess,
|
||||
getFetchConfigFailure,
|
||||
isFetchConfigPending
|
||||
isFetchConfigPending,
|
||||
modifyConfig
|
||||
} from "./config";
|
||||
|
||||
const CONFIG_URL = "/scm/api/rest/v2/config";
|
||||
@@ -94,6 +98,55 @@ describe("config fetch()", () => {
|
||||
expect(actions[1].payload).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
it("should successfully modify config", () => {
|
||||
fetchMock.putOnce("http://localhost:8081/scm/api/rest/v2/config", {
|
||||
status: 204
|
||||
});
|
||||
|
||||
const store = mockStore({});
|
||||
|
||||
return store.dispatch(modifyConfig(config)).then(() => {
|
||||
const actions = store.getActions();
|
||||
expect(actions[0].type).toEqual(MODIFY_CONFIG_PENDING);
|
||||
expect(actions[1].type).toEqual(MODIFY_CONFIG_SUCCESS);
|
||||
expect(actions[1].payload).toEqual(config);
|
||||
});
|
||||
});
|
||||
|
||||
it("should call the callback after modifying config", () => {
|
||||
fetchMock.putOnce("http://localhost:8081/scm/api/rest/v2/config", {
|
||||
status: 204
|
||||
});
|
||||
|
||||
let called = false;
|
||||
const callback = () => {
|
||||
called = true;
|
||||
};
|
||||
const store = mockStore({});
|
||||
|
||||
return store.dispatch(modifyConfig(config, callback)).then(() => {
|
||||
const actions = store.getActions();
|
||||
expect(actions[0].type).toEqual(MODIFY_CONFIG_PENDING);
|
||||
expect(actions[1].type).toEqual(MODIFY_CONFIG_SUCCESS);
|
||||
expect(called).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it("should fail modifying config on HTTP 500", () => {
|
||||
fetchMock.putOnce("http://localhost:8081/scm/api/rest/v2/config", {
|
||||
status: 500
|
||||
});
|
||||
|
||||
const store = mockStore({});
|
||||
|
||||
return store.dispatch(modifyConfig(config)).then(() => {
|
||||
const actions = store.getActions();
|
||||
expect(actions[0].type).toEqual(MODIFY_CONFIG_PENDING);
|
||||
expect(actions[1].type).toEqual(MODIFY_CONFIG_FAILURE);
|
||||
expect(actions[1].payload).toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("config reducer", () => {
|
||||
|
||||
Reference in New Issue
Block a user