Skip to content

Commit aa5b211

Browse files
authored
chore(util-endpoints): use static partitions test data (#5220)
1 parent 0b3e338 commit aa5b211

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

packages/util-endpoints/src/lib/aws/partition.spec.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { getUserAgentPrefix, partition, setPartitionInfo, useDefaultPartitionInfo } from "./partition";
2-
import partitions from "./partitions.json";
32

43
const MOCK_DEFAULT_PARTITION = {
54
id: "aws",
@@ -89,32 +88,29 @@ describe("partition", () => {
8988
});
9089

9190
it("should allow setting a custom partitions file", async () => {
92-
const copy = JSON.parse(JSON.stringify(partitions));
91+
const copy = JSON.parse(
92+
JSON.stringify({
93+
partitions: [MOCK_DEFAULT_PARTITION, MOCK_PARTITION],
94+
})
95+
);
9396
setPartitionInfo(copy);
94-
const testRegion = "us-test-135";
97+
const testRegion = "mock-region-12345";
9598
copy.partitions[0].regions[testRegion] = {
9699
description: "not a real region",
97100
};
98101
const result = partition(testRegion);
99102
expect(result).toEqual({
100103
description: "not a real region",
101-
dnsSuffix: "amazonaws.com",
102-
dualStackDnsSuffix: "api.aws",
103104
name: "aws",
104-
supportsDualStack: true,
105-
supportsFIPS: true,
105+
dnsSuffix: "mockDefaultDnsSuffix",
106+
dualStackDnsSuffix: "mockDefaultDualStackDnsSuffix",
107+
supportsDualStack: false,
108+
supportsFIPS: false,
106109
});
107110

108111
useDefaultPartitionInfo();
109112
// result is matched by regex, but customization is no longer present.
110-
expect(partition(testRegion)).toEqual({
111-
description: void 0,
112-
dnsSuffix: "amazonaws.com",
113-
dualStackDnsSuffix: "api.aws",
114-
name: "aws",
115-
supportsDualStack: true,
116-
supportsFIPS: true,
117-
});
113+
expect(partition(testRegion)["description"]).not.toBeDefined();
118114
});
119115

120116
it("should optionally set a user agent prefix", async () => {

0 commit comments

Comments
 (0)