mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 07:55:47 +01:00
add selectors for modifyGroupPending and Failure
This commit is contained in:
@@ -134,6 +134,14 @@ export function getFetchConfigFailure(state: Object) {
|
|||||||
return getFailure(state, FETCH_CONFIG);
|
return getFailure(state, FETCH_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isModifyConfigPending(state: Object) {
|
||||||
|
return isPending(state, MODIFY_CONFIG);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getModifyConfigFailure(state: Object) {
|
||||||
|
return getFailure(state, MODIFY_CONFIG);
|
||||||
|
}
|
||||||
|
|
||||||
export function getConfig(state: Object) {
|
export function getConfig(state: Object) {
|
||||||
if (state.config && state.config.entries) {
|
if (state.config && state.config.entries) {
|
||||||
return state.config.entries;
|
return state.config.entries;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import reducer, {
|
|||||||
FETCH_CONFIG_PENDING,
|
FETCH_CONFIG_PENDING,
|
||||||
FETCH_CONFIG_SUCCESS,
|
FETCH_CONFIG_SUCCESS,
|
||||||
FETCH_CONFIG_FAILURE,
|
FETCH_CONFIG_FAILURE,
|
||||||
|
MODIFY_CONFIG,
|
||||||
MODIFY_CONFIG_PENDING,
|
MODIFY_CONFIG_PENDING,
|
||||||
MODIFY_CONFIG_SUCCESS,
|
MODIFY_CONFIG_SUCCESS,
|
||||||
MODIFY_CONFIG_FAILURE,
|
MODIFY_CONFIG_FAILURE,
|
||||||
@@ -16,6 +17,8 @@ import reducer, {
|
|||||||
getFetchConfigFailure,
|
getFetchConfigFailure,
|
||||||
isFetchConfigPending,
|
isFetchConfigPending,
|
||||||
modifyConfig,
|
modifyConfig,
|
||||||
|
isModifyConfigPending,
|
||||||
|
getModifyConfigFailure,
|
||||||
getConfig,
|
getConfig,
|
||||||
getConfigUpdatePermission
|
getConfigUpdatePermission
|
||||||
} from "./config";
|
} from "./config";
|
||||||
@@ -200,6 +203,32 @@ describe("selector tests", () => {
|
|||||||
expect(getFetchConfigFailure({})).toBe(undefined);
|
expect(getFetchConfigFailure({})).toBe(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should return true, when modify group is pending", () => {
|
||||||
|
const state = {
|
||||||
|
pending: {
|
||||||
|
[MODIFY_CONFIG]: true
|
||||||
|
}
|
||||||
|
};
|
||||||
|
expect(isModifyConfigPending(state)).toEqual(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return false, when modify config is not pending", () => {
|
||||||
|
expect(isModifyConfigPending({})).toEqual(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return error when modify config did fail", () => {
|
||||||
|
const state = {
|
||||||
|
failure: {
|
||||||
|
[MODIFY_CONFIG]: error
|
||||||
|
}
|
||||||
|
};
|
||||||
|
expect(getModifyConfigFailure(state)).toEqual(error);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return undefined when modify config did not fail", () => {
|
||||||
|
expect(getModifyConfigFailure({})).toBe(undefined);
|
||||||
|
});
|
||||||
|
|
||||||
it("should return config", () => {
|
it("should return config", () => {
|
||||||
const state = {
|
const state = {
|
||||||
config: {
|
config: {
|
||||||
@@ -209,7 +238,7 @@ describe("selector tests", () => {
|
|||||||
expect(getConfig(state)).toEqual(config);
|
expect(getConfig(state)).toEqual(config);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return configUpdatePermission", () => {
|
it("should return configUpdatePermission", () => {
|
||||||
const state = {
|
const state = {
|
||||||
config: {
|
config: {
|
||||||
configUpdatePermission: true
|
configUpdatePermission: true
|
||||||
|
|||||||
Reference in New Issue
Block a user