mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-16 10:16:16 +01:00
Extracted commonly used URL in groups.test.js to constant
This commit is contained in:
@@ -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
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user