mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 08:25:44 +01:00
Restructured Changeset Component
WIP
This commit is contained in:
@@ -92,3 +92,11 @@ export function getBranchesForNamespaceAndNameFromState(namespace: string, name:
|
||||
}
|
||||
return Object.values(state.branches[key].byNames);
|
||||
}
|
||||
|
||||
export function getBranchNames(namespace: string, name: string, state: Object) {
|
||||
const key = namespace + "/" + name;
|
||||
if (!state.branches[key]) {
|
||||
return null;
|
||||
}
|
||||
return Object.keys(state.branches[key].byNames);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
FETCH_BRANCHES_FAILURE,
|
||||
FETCH_BRANCHES_PENDING,
|
||||
FETCH_BRANCHES_SUCCESS,
|
||||
fetchBranchesByNamespaceAndName, getBranchesForNamespaceAndNameFromState
|
||||
fetchBranchesByNamespaceAndName, getBranchesForNamespaceAndNameFromState, getBranchNames
|
||||
} from "./branches";
|
||||
import reducer from "./branches";
|
||||
|
||||
@@ -128,6 +128,25 @@ describe("branch selectors", () => {
|
||||
}
|
||||
}
|
||||
};
|
||||
getBranchesForNamespaceAndNameFromState(namespace, name, state);
|
||||
})
|
||||
const branches = getBranchesForNamespaceAndNameFromState(namespace, name, state);
|
||||
expect(branches.length).toEqual(1);
|
||||
expect(branches[0]).toEqual(branch1);
|
||||
});
|
||||
|
||||
it("should return branches names", () => {
|
||||
const state = {
|
||||
branches: {
|
||||
[key]: {
|
||||
byNames: {
|
||||
"branch1": branch1,
|
||||
"branch2": branch2
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
const names = getBranchNames(namespace, name, state);
|
||||
expect(names.length).toEqual(2);
|
||||
expect(names).toContain("branch1");
|
||||
expect(names).toContain("branch2");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user