|
| 1 | +import { |
| 2 | + NODE_REGION_CONFIG_FILE_OPTIONS, |
| 3 | + NODE_REGION_CONFIG_OPTIONS, |
| 4 | + REGION_ENV_NAME, |
| 5 | + REGION_INI_NAME, |
| 6 | +} from "./config"; |
| 7 | + |
| 8 | +describe("config", () => { |
| 9 | + describe("NODE_REGION_CONFIG_OPTIONS", () => { |
| 10 | + describe("environmentVariableSelector", () => { |
| 11 | + const { environmentVariableSelector } = NODE_REGION_CONFIG_OPTIONS; |
| 12 | + it.each([undefined, "mockRegion"])(`when env[${REGION_ENV_NAME}]: %s`, (mockEndpoint) => { |
| 13 | + expect(environmentVariableSelector({ [REGION_ENV_NAME]: mockEndpoint })).toBe(mockEndpoint); |
| 14 | + }); |
| 15 | + }); |
| 16 | + |
| 17 | + describe("configFileSelector", () => { |
| 18 | + const { configFileSelector } = NODE_REGION_CONFIG_OPTIONS; |
| 19 | + it.each([undefined, "mockRegion"])(`when env[${REGION_INI_NAME}]: %s`, (mockEndpoint) => { |
| 20 | + expect(configFileSelector({ [REGION_INI_NAME]: mockEndpoint })).toBe(mockEndpoint); |
| 21 | + }); |
| 22 | + }); |
| 23 | + |
| 24 | + it("default throws error", () => { |
| 25 | + const { default: defaultKey } = NODE_REGION_CONFIG_OPTIONS; |
| 26 | + expect(() => { |
| 27 | + (defaultKey as any)(); |
| 28 | + }).toThrowError(new Error("Region is missing")); |
| 29 | + }); |
| 30 | + }); |
| 31 | + |
| 32 | + describe("NODE_REGION_CONFIG_FILE_OPTIONS", () => { |
| 33 | + it("preferredFile contains credentials", () => { |
| 34 | + const { preferredFile } = NODE_REGION_CONFIG_FILE_OPTIONS; |
| 35 | + expect(preferredFile).toBe("credentials"); |
| 36 | + }); |
| 37 | + }); |
| 38 | +}); |
0 commit comments