Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(packages): await promise assertions, cleanup test logging #6839

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clients/client-s3/test/unit/S3.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ describe("signing", () => {
return await client.putObject({
Bucket: "bucket",
Key: "some file.txt",
Body: "abcd",
});
});
});
2 changes: 1 addition & 1 deletion lib/lib-storage/src/Upload.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ describe(Upload.name, () => {
});

await upload.done();
expect(() => upload.done()).rejects.toEqual(
await expect(() => upload.done()).rejects.toEqual(
new Error("@aws-sdk/lib-storage: this instance of Upload has already executed .done(). Create a new instance.")
);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/dsql-signer/src/runtimeConfig.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe("getRuntimeConfig", () => {
hostname: "test.example.com",
};
const { credentials, region } = getRuntimeConfig(minimalParams);
expect(credentials).rejects.toEqual("Credential is missing");
expect(region).rejects.toEqual("Region is missing");
await expect(credentials).rejects.toEqual("Credential is missing");
await expect(region).rejects.toEqual("Region is missing");
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ describe(EventStreamPayloadHandler.name, () => {
vi.clearAllMocks();
});

it("should throw if request payload is not a stream", () => {
it("should throw if request payload is not a stream", async () => {
const handler = new EventStreamPayloadHandler({
messageSigner: () => Promise.resolve(mockMessageSigner),
utf8Decoder: mockUtf8Decoder,
utf8Encoder: mockUtf8encoder,
});
expect(
await expect(
handler.handle(mockNextHandler, {
request: { body: "body" } as HttpRequest,
input: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ describe(resolveEndpointDiscoveryConfig.name, () => {
});

describe("endpointDiscoveryEnabled", () => {
it.each<boolean>([false, true])(`sets to value passed in the config: %s`, (endpointDiscoveryEnabled) => {
it.each<boolean>([false, true])(`sets to value passed in the config: %s`, async (endpointDiscoveryEnabled) => {
const resolvedConfig = resolveEndpointDiscoveryConfig(
{
...mockInput,
endpointDiscoveryEnabled,
},
{ endpointDiscoveryCommandCtor }
);
expect(resolvedConfig.endpointDiscoveryEnabled()).resolves.toBe(endpointDiscoveryEnabled);
await expect(resolvedConfig.endpointDiscoveryEnabled()).resolves.toBe(endpointDiscoveryEnabled);
expect(mockInput.endpointDiscoveryEnabledProvider).not.toHaveBeenCalled();
expect(resolvedConfig.isClientEndpointDiscoveryEnabled).toStrictEqual(true);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe("checkContentLengthHeaderMiddleware", () => {
let spy: any;

beforeEach(() => {
spy = vi.spyOn(console, "warn");
spy = vi.spyOn(console, "warn").mockImplementation(() => {});
});

afterEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe(normalizeTokenProvider.name, () => {
it("returns memoized function", async () => {
const normalizedTokenProvider = normalizeTokenProvider(mockInputToken);
expect(normalizedTokenProvider).toEqual(mockMemoizeFn);
expect(mockMemoizeFn()).resolves.toEqual(mockToken);
await expect(mockMemoizeFn()).resolves.toEqual(mockToken);
});

describe("memoize isExpired", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ describe(EventStreamPayloadHandler.name, () => {
vi.clearAllMocks();
});

it("should throw if request payload is not a stream", () => {
it("should throw if request payload is not a stream", async () => {
const handler = new EventStreamPayloadHandler({
messageSigner: () => Promise.resolve(mockSigner),
utf8Decoder: mockUtf8Decoder,
utf8Encoder: mockUtf8encoder,
});
expect(
await expect(
handler.handle(mockNextHandler, {
request: { body: "body" } as HttpRequest,
input: {},
Expand Down
4 changes: 2 additions & 2 deletions packages/rds-signer/src/runtimeConfig.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe("getRuntimeConfig", () => {
port: 5432,
};
const { credentials, region } = getRuntimeConfig(minimalParams);
expect(credentials).rejects.toEqual("Credential is missing");
expect(region).rejects.toEqual("Region is missing");
await expect(credentials).rejects.toEqual("Credential is missing");
await expect(region).rejects.toEqual("Region is missing");
});
});
Loading