Skip to content

Commit 9fef50a

Browse files
author
Geoffrey Koros
committed
use a dummy base url for tests
1 parent e756cb9 commit 9fef50a

File tree

6 files changed

+14
-11
lines changed

6 files changed

+14
-11
lines changed

test/common/content/BatchRequestContent.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@ import "isomorphic-fetch";
1010
import { assert } from "chai";
1111

1212
import { BatchRequestContent, BatchRequestStep } from "../../../src/content/BatchRequestContent";
13-
import { randomString } from "../../test-helper";
14-
import { GRAPH_BASE_URL } from "../../../src/Constants";
13+
import { DUMMY_BASE_URL, randomString } from "../../test-helper";
1514

1615
const folderName = randomString();
1716
const folderDetails = {
1817
name: folderName,
1918
folder: {},
2019
};
2120

22-
const createFolderRequest = new Request(GRAPH_BASE_URL + "/me/drive/root/children", {
21+
const createFolderRequest = new Request(DUMMY_BASE_URL + "/me/drive/root/children", {
2322
method: "POST",
2423
headers: {
2524
"Content-type": "application/json",

test/common/core/HTTPClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { HTTPClient } from "../../../src/HTTPClient";
1111
import { Context } from "../../../src/IContext";
1212
import { FetchOptions } from "../../../src/IFetchOptions";
1313
import { DummyHTTPMessageHandler } from "../../DummyHTTPMessageHandler";
14-
import { GRAPH_BASE_URL } from "../../../src/Constants";
14+
import { DUMMY_BASE_URL } from "../../test-helper";
1515

1616
describe("HTTPClient.ts", () => {
1717
const httpMessageHandler: DummyHTTPMessageHandler = new DummyHTTPMessageHandler();
@@ -64,7 +64,7 @@ describe("HTTPClient.ts", () => {
6464
});
6565

6666
it("Should execute for context object with Request instance", async () => {
67-
const request: Request = new Request(GRAPH_BASE_URL + "dummy_url", {
67+
const request: Request = new Request(DUMMY_BASE_URL + "/dummy_url", {
6868
method: "GET",
6969
});
7070
const context: Context = {

test/common/middleware/AuthenticationHandler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { GRAPH_BASE_URL } from "../../../src/Constants";
1212
import { Context } from "../../../src/IContext";
1313
import { AuthenticationHandler } from "../../../src/middleware/AuthenticationHandler";
1414
import { DummyAuthenticationProvider } from "../../DummyAuthenticationProvider";
15+
import { DUMMY_BASE_URL } from "../../test-helper";
1516

1617
const dummyAuthProvider = new DummyAuthenticationProvider();
1718
const authHandler = new AuthenticationHandler(dummyAuthProvider);
@@ -26,7 +27,7 @@ describe("AuthenticationHandler.ts", async () => {
2627
});
2728
describe("Auth Headers", () => {
2829
it("Should delete Auth header when Request object is passed with non Graph URL", async () => {
29-
const request = new Request(GRAPH_BASE_URL + "test_url");
30+
const request = new Request(DUMMY_BASE_URL + "/test_url");
3031
const context: Context = {
3132
request,
3233
options: {

test/common/middleware/MiddlewareUtil.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { assert } from "chai";
99

1010
import { FetchOptions } from "../../../src/IFetchOptions";
1111
import { appendRequestHeader, generateUUID, getRequestHeader, setRequestHeader } from "../../../src/middleware/MiddlewareUtil";
12-
import { GRAPH_BASE_URL } from "../../../src/Constants";
12+
import { DUMMY_BASE_URL } from "../../test-helper";
1313

1414
describe("MiddlewareUtil.ts", async () => {
1515
function getMultipleValuesForHeader(headers: Headers, key: string): string[] {
@@ -24,7 +24,7 @@ describe("MiddlewareUtil.ts", async () => {
2424
describe("getRequestHeader", () => {
2525
const key = "Content-Type";
2626
const value = "application/json";
27-
const url = GRAPH_BASE_URL + "/dummy_url";
27+
const url = DUMMY_BASE_URL + "/dummy_url";
2828
it("Should get header from request object", () => {
2929
const request: Request = new Request(url, {
3030
method: "test",
@@ -77,7 +77,7 @@ describe("MiddlewareUtil.ts", async () => {
7777
describe("setRequestHeader", () => {
7878
const key = "Content-Type";
7979
const value = "application/json";
80-
const url = GRAPH_BASE_URL + "dummy_url";
80+
const url = DUMMY_BASE_URL + "/dummy_url";
8181
it("Should set header in request object", () => {
8282
const request: Request = new Request(url, {
8383
method: "test",
@@ -180,7 +180,7 @@ describe("MiddlewareUtil.ts", async () => {
180180
const key = "Content-Type";
181181
const value = "application/json";
182182
const firstValue = "text/html";
183-
const url = GRAPH_BASE_URL + "dummy_url";
183+
const url = DUMMY_BASE_URL + "/dummy_url";
184184
it("Should set header in request object if the header is not present", () => {
185185
const request: Request = new Request(url, {
186186
method: "test",

test/common/middleware/TelemetryHandler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { FeatureUsageFlag, TelemetryHandlerOptions } from "../../../src/middlewa
1414
import { TelemetryHandler } from "../../../src/middleware/TelemetryHandler";
1515
import { PACKAGE_VERSION } from "../../../src/Version";
1616
import { DummyHTTPMessageHandler } from "../../DummyHTTPMessageHandler";
17+
import { DUMMY_BASE_URL } from "../../test-helper";
1718

1819
describe("TelemetryHandler.ts", () => {
1920
describe("execute", function() {
@@ -121,7 +122,7 @@ describe("TelemetryHandler.ts", () => {
121122
});
122123

123124
it("Should delete Telemetry in the header when Request object is passed with non Graph URL", async () => {
124-
const request = new Request(GRAPH_BASE_URL + "test_url");
125+
const request = new Request(DUMMY_BASE_URL + "/test_url");
125126
const context: Context = {
126127
request,
127128
options: {

test/test-helper.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ export function randomString() {
1919
.toString(36)
2020
.substring(7);
2121
}
22+
23+
export const DUMMY_BASE_URL = "https://localhost";

0 commit comments

Comments
 (0)