Skip to content

Commit 809b7b5

Browse files
authored
test: fix type checks in unit tests (#6071)
1 parent 246fced commit 809b7b5

File tree

25 files changed

+62
-48
lines changed

25 files changed

+62
-48
lines changed

lib/lib-dynamodb/src/baseCommand/DynamoDBDocumentClientCommand.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import { KeyNodeChildren } from "../commands/utils";
44
import { DynamoDBDocumentClientCommand } from "./DynamoDBDocumentClientCommand";
55

66
class AnyCommand extends DynamoDBDocumentClientCommand<{}, {}, {}, {}, {}> {
7+
// @ts-ignore Property 'middlewareStack' has no initializer
78
public middlewareStack: MiddlewareStack<{}, {}>;
9+
// @ts-ignore Property 'input' has no initializer
810
public input: {};
911
protected inputKeyNodes: KeyNodeChildren = {};
1012
protected outputKeyNodes: KeyNodeChildren = {};
@@ -14,7 +16,7 @@ class AnyCommand extends DynamoDBDocumentClientCommand<{}, {}, {}, {}, {}> {
1416
protected readonly clientCommand = {
1517
middlewareStack: {
1618
argCaptor: this.argCaptor,
17-
addRelativeTo(fn, config) {
19+
addRelativeTo(fn: any, config: any) {
1820
this.argCaptor.push([fn, config]);
1921
},
2022
},

packages/cloudfront-signer/src/sign.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ describe("getSignedUrl", () => {
131131
expect(result).toBe(`${url}?Expires=${epochDateLessThan}&Key-Pair-Id=${keyPairId}&Signature=${signature}`);
132132
const parsedUrl = parseUrl(result);
133133
expect(parsedUrl).toBeDefined();
134-
const signatureQueryParam = denormalizeBase64(parsedUrl.query["Signature"] as string);
134+
const signatureQueryParam = denormalizeBase64(parsedUrl.query!["Signature"] as string);
135135
expect(verifySignature(signatureQueryParam, policyStr)).toBeTruthy();
136136
});
137137
it("should sign a URL with a custom policy containing a start date", () => {
@@ -162,7 +162,7 @@ describe("getSignedUrl", () => {
162162
expect(result).toBe(`${url}?Policy=${encodeToBase64(policyStr)}&Key-Pair-Id=${keyPairId}&Signature=${signature}`);
163163
const parsedUrl = parseUrl(result);
164164
expect(parsedUrl).toBeDefined();
165-
const signatureQueryParam = denormalizeBase64(parsedUrl.query["Signature"] as string);
165+
const signatureQueryParam = denormalizeBase64(parsedUrl.query!["Signature"] as string);
166166
expect(verifySignature(signatureQueryParam, policyStr)).toBeTruthy();
167167
});
168168
it("should sign a URL with a custom policy containing an ip address", () => {
@@ -193,7 +193,7 @@ describe("getSignedUrl", () => {
193193
expect(result).toBe(`${url}?Policy=${encodeToBase64(policyStr)}&Key-Pair-Id=${keyPairId}&Signature=${signature}`);
194194
const parsedUrl = parseUrl(result);
195195
expect(parsedUrl).toBeDefined();
196-
const signatureQueryParam = denormalizeBase64(parsedUrl.query["Signature"] as string);
196+
const signatureQueryParam = denormalizeBase64(parsedUrl.query!["Signature"] as string);
197197
expect(verifySignature(signatureQueryParam, policyStr)).toBeTruthy();
198198
});
199199
it("should sign a URL with a custom policy containing a start date and ip address", () => {
@@ -228,7 +228,7 @@ describe("getSignedUrl", () => {
228228
expect(result).toBe(`${url}?Policy=${encodeToBase64(policyStr)}&Key-Pair-Id=${keyPairId}&Signature=${signature}`);
229229
const parsedUrl = parseUrl(result);
230230
expect(parsedUrl).toBeDefined();
231-
const signatureQueryParam = denormalizeBase64(parsedUrl.query["Signature"] as string);
231+
const signatureQueryParam = denormalizeBase64(parsedUrl.query!["Signature"] as string);
232232
expect(verifySignature(signatureQueryParam, policyStr)).toBeTruthy();
233233
});
234234
it("should allow an ip address with and without a mask", () => {

packages/core/src/client/emitWarningIfUnsupportedVersion.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
describe("emitWarningIfUnsupportedVersion", () => {
2-
let emitWarningIfUnsupportedVersion;
2+
let emitWarningIfUnsupportedVersion: any;
33
const emitWarning = process.emitWarning;
44
const supportedVersion = "16.0.0";
55

packages/core/src/protocols/xml/parseXmlBody.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe(parseXmlBody.name, () => {
4343
<ID>string</ID>
4444
</Owner>
4545
`);
46-
const parsed = await parseXmlBody(xml, context as any as SerdeContext).catch((_) => _);
46+
const parsed = await parseXmlBody(xml, context as any as SerdeContext).catch((_: any) => _);
4747
expect(parsed.toString()).toEqual(`Error: Unclosed tag 'ListAllMyBucketsResult'.:2:1`);
4848
});
4949

@@ -54,7 +54,7 @@ describe(parseXmlBody.name, () => {
5454
<Bucket>
5555
<CreationDate>timestamp</Creatio
5656
`);
57-
const parsed = await parseXmlBody(xml, context as any as SerdeContext).catch((_) => _);
57+
const parsed = await parseXmlBody(xml, context as any as SerdeContext).catch((_: any) => _);
5858
expect(parsed.toString()).toEqual(`Error: Closing tag 'Creatio' doesn't have proper closing.:6:1`);
5959
});
6060
});

packages/credential-provider-ini/src/resolveAssumeRoleCredentials.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ describe(resolveAssumeRoleCredentials.name, () => {
110110
duration_seconds: "2000",
111111
});
112112

113-
const getMockProfilesWithCredSource = (additionalData) => ({
113+
const getMockProfilesWithCredSource = (additionalData: any) => ({
114114
[mockProfileName]: {
115115
credential_source: mockCredentialSource,
116116
...additionalData,

packages/credential-provider-process/src/getValidatedProcessCredentials.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe(getValidatedProcessCredentials.name, () => {
1818
Expiration: mockExpiration,
1919
});
2020

21-
it.each([undefined, 2])("throws Error when Version is %s", (Version) => {
21+
it.each([2])("throws Error when Version is %s", (Version) => {
2222
expect(() => {
2323
getValidatedProcessCredentials(mockProfileName, {
2424
...getMockProcessCreds(),

packages/credential-provider-sso/src/validateSsoProfile.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ describe(validateSsoProfile.name, () => {
2020
"throws if '%s' is missing from profile",
2121
(key) => {
2222
const profileToVerify = getMockSsoProfile();
23+
// @ts-ignore Element implicitly has an 'any' type
2324
delete profileToVerify[key];
2425

2526
expect(() => {
@@ -38,6 +39,7 @@ describe(validateSsoProfile.name, () => {
3839

3940
it.each(["sso_session"])("does not throw if '%s' is missing from profile", (key) => {
4041
const profileToVerify = getMockSsoProfile();
42+
// @ts-ignore Element implicitly has an 'any' type
4143
delete profileToVerify[key];
4244

4345
expect(() => {

packages/endpoint-cache/src/EndpointCache.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { EndpointCache } from "./EndpointCache";
66
jest.mock("mnemonist/lru-cache");
77

88
describe(EndpointCache.name, () => {
9-
let endpointCache;
9+
let endpointCache: EndpointCache;
1010
const capacity = 100;
1111
const key = "key";
1212

packages/middleware-endpoint-discovery/src/configurations.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe("NODE_ENDPOINT_DISCOVERY_CONFIG_OPTIONS", () => {
1010
describe("environmentVariableSelector", () => {
1111
const ENV_ENDPOINT_DISCOVERY = ["AWS_ENABLE_ENDPOINT_DISCOVERY", "AWS_ENDPOINT_DISCOVERY_ENABLED"];
1212
describe.each(ENV_ENDPOINT_DISCOVERY)("env key: %p", (envKey) => {
13-
const envValues = {};
13+
const envValues: Record<string, string | undefined> = {};
1414

1515
beforeEach(() => {
1616
ENV_ENDPOINT_DISCOVERY.forEach((envKey) => {

packages/middleware-flexible-checksums/src/getChecksumAlgorithmForRequest.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ describe(getChecksumAlgorithmForRequest.name, () => {
1010
expect(getChecksumAlgorithmForRequest({}, { requestChecksumRequired: true })).toEqual(ChecksumAlgorithm.MD5);
1111
});
1212

13-
it.each([false, undefined])("returns undefined if requestChecksumRequired=%s", (requestChecksumRequired) => {
14-
expect(getChecksumAlgorithmForRequest({}, { requestChecksumRequired })).toBeUndefined();
13+
it("returns undefined if requestChecksumRequired is false", () => {
14+
expect(getChecksumAlgorithmForRequest({}, { requestChecksumRequired: false })).toBeUndefined();
1515
});
1616
});
1717

@@ -24,8 +24,8 @@ describe(getChecksumAlgorithmForRequest.name, () => {
2424
);
2525
});
2626

27-
it.each([false, undefined])("returns undefined if requestChecksumRequired=%s", (requestChecksumRequired) => {
28-
expect(getChecksumAlgorithmForRequest({}, { ...mockOptions, requestChecksumRequired })).toBeUndefined();
27+
it("returns undefined if requestChecksumRequired is false", () => {
28+
expect(getChecksumAlgorithmForRequest({}, { ...mockOptions, requestChecksumRequired: false })).toBeUndefined();
2929
});
3030
});
3131

0 commit comments

Comments
 (0)