Skip to content

Commit 4b537de

Browse files
authored
test(aws-client-api-test): add type assertions to endpoint tests (#7194)
1 parent d9c5976 commit 4b537de

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

private/aws-client-api-test/src/client-interface-tests/endpoint-requiredness-variations.spec.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
import type { EC2ProtocolClientConfig } from "@aws-sdk/aws-protocoltests-ec2";
12
import { EC2ProtocolClient } from "@aws-sdk/aws-protocoltests-ec2";
3+
import type { S3ClientConfig } from "@aws-sdk/client-s3";
24
import { S3Client } from "@aws-sdk/client-s3";
5+
import type { WeatherClientConfig } from "@aws-sdk/weather";
36
import { WeatherClient } from "@aws-sdk/weather";
7+
import type { Endpoint, EndpointV2, Exact, Provider } from "@smithy/types";
48
import { describe, expect, test as it } from "vitest";
59

610
describe("variations in the config endpoint property", () => {
@@ -9,6 +13,12 @@ describe("variations in the config endpoint property", () => {
913
const client = new S3Client({});
1014
expect(client.config.endpoint).toBeUndefined();
1115
expect(await client.config.endpoint?.()).toBeUndefined();
16+
17+
const endpointNotRequired: true = true as Exact<
18+
S3ClientConfig["endpoint"],
19+
undefined | string | Endpoint | Provider<Endpoint> | EndpointV2 | Provider<EndpointV2>
20+
>;
21+
void endpointNotRequired;
1222
});
1323

1424
it("endpoint can be set, but must be queried with an undef-check", async () => {
@@ -23,6 +33,9 @@ describe("variations in the config endpoint property", () => {
2333
protocol: "https:",
2434
query: undefined,
2535
});
36+
37+
const endpointNotGuaranteed: true = true as Exact<typeof client.config.endpoint, undefined | Provider<Endpoint>>;
38+
void endpointNotGuaranteed;
2639
});
2740
});
2841

@@ -31,6 +44,12 @@ describe("variations in the config endpoint property", () => {
3144
const client = new WeatherClient({
3245
endpoint: "https://localhost",
3346
});
47+
48+
const endpointIsRequired: true = true as Exact<
49+
WeatherClientConfig["endpoint"],
50+
string | Endpoint | Provider<Endpoint> | EndpointV2 | Provider<EndpointV2>
51+
>;
52+
void endpointIsRequired;
3453
});
3554

3655
it("config.endpoint may be queried without undef-check since it was required on input", async () => {
@@ -44,6 +63,9 @@ describe("variations in the config endpoint property", () => {
4463
protocol: "https:",
4564
query: undefined,
4665
});
66+
67+
const endpointIsGuaranteed: true = true as Exact<typeof client.config.endpoint, Provider<Endpoint>>;
68+
void endpointIsGuaranteed;
4769
});
4870
});
4971

@@ -55,6 +77,12 @@ describe("variations in the config endpoint property", () => {
5577
it("endpoint is not required", async () => {
5678
const client = new EC2ProtocolClient({});
5779
expect(client.config.endpoint).toBeInstanceOf(Function);
80+
81+
const endpointNotRequired: true = true as Exact<
82+
EC2ProtocolClientConfig["endpoint"],
83+
undefined | string | Endpoint | Provider<Endpoint> | EndpointV2 | Provider<EndpointV2>
84+
>;
85+
void endpointNotRequired;
5886
});
5987

6088
it("endpoint may be set", async () => {
@@ -79,6 +107,9 @@ describe("variations in the config endpoint property", () => {
79107
protocol: "https:",
80108
query: undefined,
81109
});
110+
111+
const endpointIsGuaranteed: true = true as Exact<typeof client.config.endpoint, Provider<Endpoint>>;
112+
void endpointIsGuaranteed;
82113
});
83114

84115
it("fips", async () => {

0 commit comments

Comments
 (0)