Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe committed Oct 28, 2024
1 parent 09a34e5 commit 7f8e93a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@ describe(FetchHttpHandler.name, () => {
const username = "foo";
const password = "bar";
const mockHttpRequest = getMockHttpRequest({ username, password });
await fetchHttpHandler.handle(mockHttpRequest).catch(error => {
expect(String(error)).toContain("TypeError: Request cannot be constructed from a URL that includes credentials");
})
await fetchHttpHandler.handle(mockHttpRequest).catch((error) => {
expect(String(error)).toContain(
"TypeError: Request cannot be constructed from a URL that includes credentials"
);
});

const mockAuth = `${mockHttpRequest.username}:${mockHttpRequest.password}`;
const expectedUrl = `${mockHttpRequest.protocol}//${mockAuth}@${mockHttpRequest.hostname}/`;
Expand Down
8 changes: 6 additions & 2 deletions packages/node-http-handler/src/server.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,19 @@ const setResponseBody = (response: ServerResponse, body: string | NodeJsRuntimeB
export const createResponseFunction =
(httpResp: HttpResponse) => (request: IncomingMessage, response: ServerResponse) => {
response.statusCode = httpResp.statusCode;
response.statusMessage = httpResp.reason;
if (httpResp.reason) {
response.statusMessage = httpResp.reason;
}
setResponseHeaders(response, httpResp.headers);
setResponseBody(response, httpResp.body);
};

export const createResponseFunctionWithDelay =
(httpResp: HttpResponse, delay: number) => (request: IncomingMessage, response: ServerResponse) => {
response.statusCode = httpResp.statusCode;
response.statusMessage = httpResp.reason;
if (httpResp.reason) {
response.statusMessage = httpResp.reason;
}
setResponseHeaders(response, httpResp.headers);
timing.setTimeout(() => setResponseBody(response, httpResp.body), delay);
};
Expand Down

0 comments on commit 7f8e93a

Please sign in to comment.