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 d600379
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
8 changes: 8 additions & 0 deletions .changeset/sweet-lions-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@smithy/fetch-http-handler": minor
"@smithy/node-http-handler": minor
"@smithy/util-stream": minor
"@smithy/types": minor
---

vitest compatibility
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
2 changes: 1 addition & 1 deletion packages/fetch-http-handler/src/fetch-http-handler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let timeoutSpy: any;
(global as any).Headers = vi.fn();
const globalFetch = global.fetch;

describe(FetchHttpHandler.name, () => {
(typeof Blob === "function" ? describe : describe.skip)(FetchHttpHandler.name, () => {
beforeEach(() => {
(global as any).AbortController = void 0;
vi.clearAllMocks();
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 d600379

Please sign in to comment.