mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 23:15:43 +01:00
Fix missing encoding of useBranch hook (#1798)
This commit is contained in:
@@ -51,6 +51,16 @@ describe("Test branches hooks", () => {
|
||||
},
|
||||
};
|
||||
|
||||
const feature: Branch = {
|
||||
name: "feature/something-special",
|
||||
revision: "42",
|
||||
_links: {
|
||||
delete: {
|
||||
href: "/hog/branches/feature%2Fsomething-special",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const branches: BranchCollection = {
|
||||
_embedded: {
|
||||
branches: [develop],
|
||||
@@ -101,10 +111,10 @@ describe("Test branches hooks", () => {
|
||||
});
|
||||
|
||||
describe("useBranch tests", () => {
|
||||
const fetchBranch = async () => {
|
||||
fetchMock.getOnce("/api/v2/hog/branches/develop", develop);
|
||||
const fetchBranch = async (name: string, branch: Branch) => {
|
||||
fetchMock.getOnce("/api/v2/hog/branches/" + encodeURIComponent(name), branch);
|
||||
|
||||
const { result, waitFor } = renderHook(() => useBranch(repository, "develop"), {
|
||||
const { result, waitFor } = renderHook(() => useBranch(repository, name), {
|
||||
wrapper: createWrapper(undefined, queryClient),
|
||||
});
|
||||
|
||||
@@ -118,9 +128,14 @@ describe("Test branches hooks", () => {
|
||||
};
|
||||
|
||||
it("should return branch", async () => {
|
||||
const branch = await fetchBranch();
|
||||
const branch = await fetchBranch("develop", develop);
|
||||
expect(branch).toEqual(develop);
|
||||
});
|
||||
|
||||
it("should escape branch name", async () => {
|
||||
const branch = await fetchBranch("feature/something-special", feature);
|
||||
expect(branch).toEqual(feature);
|
||||
});
|
||||
});
|
||||
|
||||
describe("useCreateBranch tests", () => {
|
||||
|
||||
Reference in New Issue
Block a user