Skip to content

Commit 2948296

Browse files
committed
chore: test typefixes and update to integ test model
1 parent 0322e0a commit 2948296

File tree

50 files changed

+209
-118
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+209
-118
lines changed

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@ generate-protocol-tests:
1818
test-protocols:
1919
(cd ./private/smithy-rpcv2-cbor && npx vitest run --globals)
2020

21+
test-unit:
22+
yarn g:vitest run -c vitest.config.ts
23+
24+
test-browser:
25+
yarn g:vitest run -c vitest.config.browser.ts
26+
27+
# typecheck for test code.
28+
test-types:
29+
npx tsc -p tsconfig.test.json
30+
31+
test-integration:
32+
make test-browser
33+
yarn g:vitest run -c vitest.config.integ.ts
34+
make test-types
35+
2136
turbo-clean:
2237
@read -p "Are you sure you want to delete your local cache? [y/N]: " ans && [ $${ans:-N} = y ]
2338
@echo "\nDeleted cache folders: \n--------"

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"scripts": {
88
"clean": "turbo run clean --force --parallel",
99
"build": "turbo run build",
10-
"test": "turbo run test",
11-
"test:integration": "yarn build-test-packages && turbo run test:integration",
10+
"test": "make test-unit",
11+
"test:integration": "yarn build-test-packages && make test-integration",
1212
"test:protocols": "make generate-protocol-tests test-protocols",
1313
"lint": "turbo run lint",
1414
"lint-fix": "turbo run lint -- --fix",

packages/config-resolver/src/regionConfig/isFipsRegion.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ describe(isFipsRegion.name, () => {
1212
});
1313

1414
it.each([undefined, null])("returns false for %s", (input) => {
15-
expect(isFipsRegion(input)).toEqual(false);
15+
expect(isFipsRegion(input as any)).toEqual(false);
1616
});
1717
});

packages/config-resolver/src/regionConfig/resolveRegionConfig.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ describe("RegionConfig", () => {
5454
});
5555

5656
describe("useFipsEndpoint", () => {
57-
let mockRegionProvider;
58-
let mockUseFipsEndpoint;
57+
let mockRegionProvider: () => Promise<string>;
58+
let mockUseFipsEndpoint: () => Promise<boolean>;
5959

6060
beforeEach(() => {
6161
mockRegionProvider = vi.fn().mockResolvedValueOnce(Promise.resolve(mockRegion));

packages/config-resolver/src/regionInfo/getRegionInfo.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ describe(getRegionInfo.name, () => {
5656
const getMockResolvedRegion = (regionCase: RegionCase): string =>
5757
regionCase !== RegionCase.ENDPOINT ? mockRegion : mockEndpointRegion;
5858

59-
const getMockResolvedPartitionOptions = (partitionHash) => ({ partitionHash });
59+
const getMockResolvedPartitionOptions = (partitionHash: PartitionHash) => ({ partitionHash });
6060

61-
const getMockRegionInfoOptions = (regionHash, getResolvedPartitionOptions) => ({
61+
const getMockRegionInfoOptions = (regionHash: RegionHash, getResolvedPartitionOptions: any) => ({
6262
...getResolvedPartitionOptions,
6363
signingService: mockSigningService,
6464
regionHash,

packages/config-resolver/src/regionInfo/getResolvedPartition.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ describe(getResolvedPartition.name, () => {
3232
});
3333

3434
it("returns aws if partitionHash is empty", () => {
35-
expect(getResolvedPartition(mockRegion, { partitionHash: undefined })).toBe("aws");
35+
expect(getResolvedPartition(mockRegion, { partitionHash: undefined as any })).toBe("aws");
3636
});
3737
});

packages/core/src/submodules/cbor/cbor.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as fs from "fs";
2+
// @ts-ignore
23
import JSONbig from "json-bigint";
34
import * as path from "path";
45
import { describe, expect, test as it } from "vitest";
@@ -290,7 +291,7 @@ describe("cbor", () => {
290291
return scalar * sum * exponentScalar;
291292
}
292293

293-
function translateTestData(data: any) {
294+
function translateTestData(data: any): any {
294295
const [type, value] = Object.entries(data)[0] as [string, any];
295296
switch (type) {
296297
case "null":

packages/core/src/submodules/schema/middleware/schemaDeserializationMiddleware.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ describe(schemaDeserializationMiddleware.name, () => {
8585
expect(mockNext).toHaveBeenCalledWith(mockArgs);
8686
expect(mockDeserializer).toHaveBeenCalledTimes(1);
8787
expect(mockDeserializer).toHaveBeenCalledWith(
88-
undefined as SchemaRef,
88+
undefined as any as SchemaRef,
8989
{
9090
...mockOptions,
9191
__smithy_context: {},

packages/core/src/submodules/schema/middleware/schemaSerializationMiddleware.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe(schemaSerializationMiddleware.name, () => {
5959
await expect(schemaSerializationMiddleware(mockOptions)(mockNext, {})(mockArgs)).resolves.toStrictEqual(mockReturn);
6060

6161
expect(mockSerializer).toHaveBeenCalledTimes(1);
62-
expect(mockSerializer).toHaveBeenCalledWith(undefined as SchemaRef, mockArgs.input, {
62+
expect(mockSerializer).toHaveBeenCalledWith(undefined as unknown as SchemaRef, mockArgs.input, {
6363
...mockOptions,
6464
__smithy_context: {},
6565
});

packages/credential-provider-imds/src/remoteProvider/httpRequest.spec.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import EventEmitter from "events";
2020
import { request } from "http";
2121

2222
describe("httpRequest", () => {
23-
let port: number;
2423
const hostname = "localhost";
2524
const path = "/";
2625

@@ -53,7 +52,7 @@ describe("httpRequest", () => {
5352

5453
mockResponse({ expectedResponse });
5554

56-
const response = await httpRequest({ hostname, path, port });
55+
const response = await httpRequest({ hostname, path });
5756
expect(response.toString()).toStrictEqual(expectedResponse);
5857
});
5958

@@ -62,7 +61,7 @@ describe("httpRequest", () => {
6261
const expectedResponse = "expectedResponse";
6362
mockResponse({ expectedResponse });
6463

65-
const response = await httpRequest({ hostname, path, port, method });
64+
const response = await httpRequest({ hostname, path, method });
6665
expect(response.toString()).toStrictEqual(expectedResponse);
6766
});
6867

@@ -71,7 +70,7 @@ describe("httpRequest", () => {
7170
const encapsulatedIPv6Hostname = "[::1]";
7271
mockResponse({ expectedResponse });
7372

74-
const response = await httpRequest({ hostname: encapsulatedIPv6Hostname, path, port });
73+
const response = await httpRequest({ hostname: encapsulatedIPv6Hostname, path });
7574
expect(response.toString()).toStrictEqual(expectedResponse);
7675
});
7776
});
@@ -84,7 +83,7 @@ describe("httpRequest", () => {
8483
expectedResponse: "continue",
8584
});
8685

87-
await expect(httpRequest({ hostname, path, port })).rejects.toStrictEqual(
86+
await expect(httpRequest({ hostname, path })).rejects.toStrictEqual(
8887
Object.assign(new ProviderError("Error response received from instance metadata service"), { statusCode })
8988
);
9089
});
@@ -102,7 +101,7 @@ describe("httpRequest", () => {
102101
return request;
103102
}) as any);
104103

105-
await expect(httpRequest({ hostname, path, port })).rejects.toStrictEqual(
104+
await expect(httpRequest({ hostname, path })).rejects.toStrictEqual(
106105
new ProviderError("Unable to connect to instance metadata service")
107106
);
108107
});
@@ -131,7 +130,7 @@ describe("httpRequest", () => {
131130
return request;
132131
}) as any);
133132

134-
await expect(httpRequest({ hostname, path, port, timeout })).rejects.toStrictEqual(
133+
await expect(httpRequest({ hostname, path, timeout })).rejects.toStrictEqual(
135134
new ProviderError("TimeoutError from instance metadata service")
136135
);
137136
});

0 commit comments

Comments
 (0)