From d00c487f362cf3656ab2f5d0436b88c2abe73c88 Mon Sep 17 00:00:00 2001 From: Philipp Czora Date: Tue, 6 Nov 2018 13:14:02 +0100 Subject: [PATCH] Extracted commonly used URL in tests to constant --- scm-ui/src/users/modules/users.test.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scm-ui/src/users/modules/users.test.js b/scm-ui/src/users/modules/users.test.js index dd3abdf47a..ac4d1c97a9 100644 --- a/scm-ui/src/users/modules/users.test.js +++ b/scm-ui/src/users/modules/users.test.js @@ -124,6 +124,7 @@ const response = { const URL = "users"; const USERS_URL = "/api/v2/users"; +const USER_ZAPHOD_URL = "http://localhost:8081/api/v2/users/zaphod"; const error = new Error("KAPUTT"); @@ -193,7 +194,7 @@ describe("users fetch()", () => { }); it("should sucessfully fetch single user", () => { - fetchMock.getOnce("http://localhost:8081/api/v2/users/zaphod", userZaphod); + fetchMock.getOnce(USER_ZAPHOD_URL, userZaphod); const store = mockStore({}); return store.dispatch(fetchUserByLink(userZaphod)).then(() => { @@ -205,7 +206,7 @@ describe("users fetch()", () => { }); it("should fail fetching single user on HTTP 500", () => { - fetchMock.getOnce("http://localhost:8081/api/v2/users/zaphod", { + fetchMock.getOnce(USER_ZAPHOD_URL, { status: 500 }); @@ -268,10 +269,10 @@ describe("users fetch()", () => { }); it("successfully update user", () => { - fetchMock.putOnce("http://localhost:8081/api/v2/users/zaphod", { + fetchMock.putOnce(USER_ZAPHOD_URL, { status: 204 }); - fetchMock.getOnce("http://localhost:8081/api/v2/users/zaphod", userZaphod); + fetchMock.getOnce(USER_ZAPHOD_URL, userZaphod); const store = mockStore({}); return store.dispatch(modifyUser(userZaphod)).then(() => { @@ -284,10 +285,10 @@ describe("users fetch()", () => { }); it("should call callback, after successful modified user", () => { - fetchMock.putOnce("http://localhost:8081/api/v2/users/zaphod", { + fetchMock.putOnce(USER_ZAPHOD_URL, { status: 204 }); - fetchMock.getOnce("http://localhost:8081/api/v2/users/zaphod", userZaphod); + fetchMock.getOnce(USER_ZAPHOD_URL, userZaphod); let called = false; const callMe = () => {