forked from aws/aws-sdk-js-v3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNodeDisableMultiregionAccessPointConfigOptions.spec.ts
More file actions
50 lines (42 loc) · 1.96 KB
/
NodeDisableMultiregionAccessPointConfigOptions.spec.ts
File metadata and controls
50 lines (42 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { booleanSelector, SelectorType } from "@aws-sdk/util-config-provider";
import {
NODE_DISABLE_MULTIREGION_ACCESS_POINT_CONFIG_OPTIONS,
NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME,
NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME,
} from "./NodeDisableMultiregionAccessPointConfigOptions";
jest.mock("@aws-sdk/util-config-provider");
describe("NODE_USE_ARN_REGION_CONFIG_OPTIONS", () => {
afterEach(() => {
jest.clearAllMocks();
});
const test = (func: Function, obj: { [key: string]: string }, key: string, type: SelectorType) => {
it.each([true, false, undefined])("returns %s", (output) => {
(booleanSelector as jest.Mock).mockReturnValueOnce(output);
expect(func(obj)).toEqual(output);
expect(booleanSelector).toBeCalledWith(obj, key, type);
});
it("throws error", () => {
const mockError = new Error("error");
(booleanSelector as jest.Mock).mockImplementationOnce(() => {
throw mockError;
});
expect(() => {
func(obj);
}).toThrow(mockError);
});
};
describe("calls booleanSelector for environmentVariableSelector", () => {
const env: { [NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME]: any } = {} as any;
const { environmentVariableSelector } = NODE_DISABLE_MULTIREGION_ACCESS_POINT_CONFIG_OPTIONS;
test(environmentVariableSelector, env, NODE_DISABLE_MULTIREGION_ACCESS_POINT_ENV_NAME, SelectorType.ENV);
});
describe("calls booleanSelector for configFileSelector", () => {
const profileContent: { [NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME]: any } = {} as any;
const { configFileSelector } = NODE_DISABLE_MULTIREGION_ACCESS_POINT_CONFIG_OPTIONS;
test(configFileSelector, profileContent, NODE_DISABLE_MULTIREGION_ACCESS_POINT_INI_NAME, SelectorType.CONFIG);
});
it("returns false for default", () => {
const { default: defaultValue } = NODE_DISABLE_MULTIREGION_ACCESS_POINT_CONFIG_OPTIONS;
expect(defaultValue).toEqual(false);
});
});