|
| 1 | +import { getRealRegion } from "./getRealRegion"; |
| 2 | +import { isFipsRegion } from "./isFipsRegion"; |
| 3 | + |
| 4 | +jest.mock("./isFipsRegion"); |
| 5 | + |
| 6 | +describe(getRealRegion.name, () => { |
| 7 | + beforeEach(() => { |
| 8 | + (isFipsRegion as jest.Mock).mockReturnValue(true); |
| 9 | + }); |
| 10 | + |
| 11 | + afterEach(() => { |
| 12 | + expect(isFipsRegion).toHaveBeenCalledTimes(1); |
| 13 | + jest.clearAllMocks(); |
| 14 | + }); |
| 15 | + |
| 16 | + it("returns provided region if it's not FIPS", () => { |
| 17 | + const mockRegion = "mockRegion"; |
| 18 | + (isFipsRegion as jest.Mock).mockReturnValue(false); |
| 19 | + expect(getRealRegion(mockRegion)).toStrictEqual(mockRegion); |
| 20 | + }); |
| 21 | + |
| 22 | + describe("FIPS regions", () => { |
| 23 | + it.each(["fips-aws-global", "aws-fips"])(`returns "us-east-1" for "%s"`, (input) => { |
| 24 | + expect(getRealRegion(input)).toStrictEqual("us-east-1"); |
| 25 | + }); |
| 26 | + |
| 27 | + it.each([ |
| 28 | + ["us-west-1", "us-west-1-fips"], |
| 29 | + ["us-west-1", "fips-us-west-1"], |
| 30 | + ["us-west-1", "fips-dkr-us-west-1"], |
| 31 | + ["us-west-1", "fips-prod-us-west-1"], |
| 32 | + ])(`returns "%s" for "%s"`, (output, input) => { |
| 33 | + expect(getRealRegion(input)).toStrictEqual(output); |
| 34 | + }); |
| 35 | + }); |
| 36 | +}); |
0 commit comments