Skip to content

Commit e504341

Browse files
authoredJan 22, 2025··
test(packages): await promise assertions, cleanup test logging (#6839)
1 parent 84d6c18 commit e504341

File tree

9 files changed

+14
-13
lines changed

9 files changed

+14
-13
lines changed
 

‎clients/client-s3/test/unit/S3.spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ describe("signing", () => {
304304
return await client.putObject({
305305
Bucket: "bucket",
306306
Key: "some file.txt",
307+
Body: "abcd",
307308
});
308309
});
309310
});

‎lib/lib-storage/src/Upload.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ describe(Upload.name, () => {
788788
});
789789

790790
await upload.done();
791-
expect(() => upload.done()).rejects.toEqual(
791+
await expect(() => upload.done()).rejects.toEqual(
792792
new Error("@aws-sdk/lib-storage: this instance of Upload has already executed .done(). Create a new instance.")
793793
);
794794
});

‎packages/dsql-signer/src/runtimeConfig.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe("getRuntimeConfig", () => {
1313
hostname: "test.example.com",
1414
};
1515
const { credentials, region } = getRuntimeConfig(minimalParams);
16-
expect(credentials).rejects.toEqual("Credential is missing");
17-
expect(region).rejects.toEqual("Region is missing");
16+
await expect(credentials).rejects.toEqual("Credential is missing");
17+
await expect(region).rejects.toEqual("Region is missing");
1818
});
1919
});

‎packages/eventstream-handler-node/src/EventStreamPayloadHandler.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ describe(EventStreamPayloadHandler.name, () => {
3636
vi.clearAllMocks();
3737
});
3838

39-
it("should throw if request payload is not a stream", () => {
39+
it("should throw if request payload is not a stream", async () => {
4040
const handler = new EventStreamPayloadHandler({
4141
messageSigner: () => Promise.resolve(mockMessageSigner),
4242
utf8Decoder: mockUtf8Decoder,
4343
utf8Encoder: mockUtf8encoder,
4444
});
45-
expect(
45+
await expect(
4646
handler.handle(mockNextHandler, {
4747
request: { body: "body" } as HttpRequest,
4848
input: {},

‎packages/middleware-endpoint-discovery/src/resolveEndpointDiscoveryConfig.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ describe(resolveEndpointDiscoveryConfig.name, () => {
4242
});
4343

4444
describe("endpointDiscoveryEnabled", () => {
45-
it.each<boolean>([false, true])(`sets to value passed in the config: %s`, (endpointDiscoveryEnabled) => {
45+
it.each<boolean>([false, true])(`sets to value passed in the config: %s`, async (endpointDiscoveryEnabled) => {
4646
const resolvedConfig = resolveEndpointDiscoveryConfig(
4747
{
4848
...mockInput,
4949
endpointDiscoveryEnabled,
5050
},
5151
{ endpointDiscoveryCommandCtor }
5252
);
53-
expect(resolvedConfig.endpointDiscoveryEnabled()).resolves.toBe(endpointDiscoveryEnabled);
53+
await expect(resolvedConfig.endpointDiscoveryEnabled()).resolves.toBe(endpointDiscoveryEnabled);
5454
expect(mockInput.endpointDiscoveryEnabledProvider).not.toHaveBeenCalled();
5555
expect(resolvedConfig.isClientEndpointDiscoveryEnabled).toStrictEqual(true);
5656
});

‎packages/middleware-sdk-s3/src/check-content-length-header.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe("checkContentLengthHeaderMiddleware", () => {
99
let spy: any;
1010

1111
beforeEach(() => {
12-
spy = vi.spyOn(console, "warn");
12+
spy = vi.spyOn(console, "warn").mockImplementation(() => {});
1313
});
1414

1515
afterEach(() => {

‎packages/middleware-token/src/normalizeTokenProvider.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe(normalizeTokenProvider.name, () => {
3232
it("returns memoized function", async () => {
3333
const normalizedTokenProvider = normalizeTokenProvider(mockInputToken);
3434
expect(normalizedTokenProvider).toEqual(mockMemoizeFn);
35-
expect(mockMemoizeFn()).resolves.toEqual(mockToken);
35+
await expect(mockMemoizeFn()).resolves.toEqual(mockToken);
3636
});
3737

3838
describe("memoize isExpired", () => {

‎packages/middleware-websocket/src/EventStreamPayloadHandler.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ describe(EventStreamPayloadHandler.name, () => {
2929
vi.clearAllMocks();
3030
});
3131

32-
it("should throw if request payload is not a stream", () => {
32+
it("should throw if request payload is not a stream", async () => {
3333
const handler = new EventStreamPayloadHandler({
3434
messageSigner: () => Promise.resolve(mockSigner),
3535
utf8Decoder: mockUtf8Decoder,
3636
utf8Encoder: mockUtf8encoder,
3737
});
38-
expect(
38+
await expect(
3939
handler.handle(mockNextHandler, {
4040
request: { body: "body" } as HttpRequest,
4141
input: {},

‎packages/rds-signer/src/runtimeConfig.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe("getRuntimeConfig", () => {
1515
port: 5432,
1616
};
1717
const { credentials, region } = getRuntimeConfig(minimalParams);
18-
expect(credentials).rejects.toEqual("Credential is missing");
19-
expect(region).rejects.toEqual("Region is missing");
18+
await expect(credentials).rejects.toEqual("Credential is missing");
19+
await expect(region).rejects.toEqual("Region is missing");
2020
});
2121
});

0 commit comments

Comments
 (0)
Please sign in to comment.