Skip to content

Commit

Permalink
chore(util-endpoints): use static partitions test data (#5220)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe committed Sep 14, 2023
1 parent 0b3e338 commit aa5b211
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions packages/util-endpoints/src/lib/aws/partition.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { getUserAgentPrefix, partition, setPartitionInfo, useDefaultPartitionInfo } from "./partition";
import partitions from "./partitions.json";

const MOCK_DEFAULT_PARTITION = {
id: "aws",
Expand Down Expand Up @@ -89,32 +88,29 @@ describe("partition", () => {
});

it("should allow setting a custom partitions file", async () => {
const copy = JSON.parse(JSON.stringify(partitions));
const copy = JSON.parse(
JSON.stringify({
partitions: [MOCK_DEFAULT_PARTITION, MOCK_PARTITION],
})
);
setPartitionInfo(copy);
const testRegion = "us-test-135";
const testRegion = "mock-region-12345";
copy.partitions[0].regions[testRegion] = {
description: "not a real region",
};
const result = partition(testRegion);
expect(result).toEqual({
description: "not a real region",
dnsSuffix: "amazonaws.com",
dualStackDnsSuffix: "api.aws",
name: "aws",
supportsDualStack: true,
supportsFIPS: true,
dnsSuffix: "mockDefaultDnsSuffix",
dualStackDnsSuffix: "mockDefaultDualStackDnsSuffix",
supportsDualStack: false,
supportsFIPS: false,
});

useDefaultPartitionInfo();
// result is matched by regex, but customization is no longer present.
expect(partition(testRegion)).toEqual({
description: void 0,
dnsSuffix: "amazonaws.com",
dualStackDnsSuffix: "api.aws",
name: "aws",
supportsDualStack: true,
supportsFIPS: true,
});
expect(partition(testRegion)["description"]).not.toBeDefined();
});

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

0 comments on commit aa5b211

Please sign in to comment.