diff --git a/scm-ui/src/groups/modules/groups.test.js b/scm-ui/src/groups/modules/groups.test.js index 970e96ba70..57d41975a1 100644 --- a/scm-ui/src/groups/modules/groups.test.js +++ b/scm-ui/src/groups/modules/groups.test.js @@ -47,6 +47,7 @@ import reducer, { getCreateGroupLink } from "./groups"; const GROUPS_URL = "/api/v2/groups"; +const URL_HUMAN_GROUP = "http://localhost:8081/api/v2/groups/humanGroup"; const URL = "/groups"; const error = new Error("You have an error!"); @@ -60,13 +61,13 @@ const humanGroup = { members: ["userZaphod"], _links: { self: { - href: "http://localhost:8081/api/v2/groups/humanGroup" + href: URL_HUMAN_GROUP }, delete: { - href: "http://localhost:8081/api/v2/groups/humanGroup" + href: URL_HUMAN_GROUP }, update: { - href: "http://localhost:8081/api/v2/groups/humanGroup" + href: URL_HUMAN_GROUP } }, _embedded: { @@ -199,10 +200,7 @@ describe("groups fetch()", () => { }); it("should sucessfully fetch single group", () => { - fetchMock.getOnce( - "http://localhost:8081/api/v2/groups/humanGroup", - humanGroup - ); + fetchMock.getOnce(URL_HUMAN_GROUP, humanGroup); const store = mockStore({}); return store.dispatch(fetchGroupByLink(humanGroup)).then(() => { @@ -214,7 +212,7 @@ describe("groups fetch()", () => { }); it("should fail fetching single group on HTTP 500", () => { - fetchMock.getOnce("http://localhost:8081/api/v2/groups/humanGroup", { + fetchMock.getOnce(URL_HUMAN_GROUP, { status: 500 }); @@ -274,13 +272,10 @@ describe("groups fetch()", () => { }); it("should successfully modify group", () => { - fetchMock.putOnce("http://localhost:8081/api/v2/groups/humanGroup", { + fetchMock.putOnce(URL_HUMAN_GROUP, { status: 204 }); - fetchMock.getOnce( - "http://localhost:8081/api/v2/groups/humanGroup", - humanGroup - ); + fetchMock.getOnce(URL_HUMAN_GROUP, humanGroup); const store = mockStore({}); @@ -294,13 +289,10 @@ describe("groups fetch()", () => { }); it("should call the callback after modifying group", () => { - fetchMock.putOnce("http://localhost:8081/api/v2/groups/humanGroup", { + fetchMock.putOnce(URL_HUMAN_GROUP, { status: 204 }); - fetchMock.getOnce( - "http://localhost:8081/api/v2/groups/humanGroup", - humanGroup - ); + fetchMock.getOnce(URL_HUMAN_GROUP, humanGroup); let called = false; const callback = () => { @@ -318,7 +310,7 @@ describe("groups fetch()", () => { }); it("should fail modifying group on HTTP 500", () => { - fetchMock.putOnce("http://localhost:8081/api/v2/groups/humanGroup", { + fetchMock.putOnce(URL_HUMAN_GROUP, { status: 500 }); @@ -333,7 +325,7 @@ describe("groups fetch()", () => { }); it("should delete successfully group humanGroup", () => { - fetchMock.deleteOnce("http://localhost:8081/api/v2/groups/humanGroup", { + fetchMock.deleteOnce(URL_HUMAN_GROUP, { status: 204 }); @@ -348,7 +340,7 @@ describe("groups fetch()", () => { }); it("should call the callback, after successful delete", () => { - fetchMock.deleteOnce("http://localhost:8081/api/v2/groups/humanGroup", { + fetchMock.deleteOnce(URL_HUMAN_GROUP, { status: 204 }); @@ -364,7 +356,7 @@ describe("groups fetch()", () => { }); it("should fail to delete group humanGroup", () => { - fetchMock.deleteOnce("http://localhost:8081/api/v2/groups/humanGroup", { + fetchMock.deleteOnce(URL_HUMAN_GROUP, { status: 500 });