@@ -7,18 +7,26 @@ vi.mock("@aws-sdk/endpoint-cache");
7
7
8
8
describe ( resolveEndpointDiscoveryConfig . name , ( ) => {
9
9
const endpointDiscoveryCommandCtor = vi . fn ( ) ;
10
- const mockInput = {
10
+ const mockInput = ( ) => ( {
11
11
isCustomEndpoint : false ,
12
12
credentials : vi . fn ( ) ,
13
13
endpointDiscoveryEnabledProvider : vi . fn ( ) ,
14
- } ;
14
+ } ) ;
15
15
16
16
afterEach ( ( ) => {
17
17
vi . clearAllMocks ( ) ;
18
18
} ) ;
19
19
20
+ it ( "maintains object custody" , ( ) => {
21
+ const input = {
22
+ credentials : vi . fn ( ) ,
23
+ endpointDiscoveryEnabledProvider : async ( ) => false ,
24
+ } ;
25
+ expect ( resolveEndpointDiscoveryConfig ( input , { endpointDiscoveryCommandCtor } ) ) . toBe ( input ) ;
26
+ } ) ;
27
+
20
28
it ( "assigns endpointDiscoveryCommandCtor in resolvedConfig" , ( ) => {
21
- const resolvedConfig = resolveEndpointDiscoveryConfig ( mockInput , { endpointDiscoveryCommandCtor } ) ;
29
+ const resolvedConfig = resolveEndpointDiscoveryConfig ( mockInput ( ) , { endpointDiscoveryCommandCtor } ) ;
22
30
expect ( resolvedConfig . endpointDiscoveryCommandCtor ) . toStrictEqual ( endpointDiscoveryCommandCtor ) ;
23
31
} ) ;
24
32
@@ -27,7 +35,7 @@ describe(resolveEndpointDiscoveryConfig.name, () => {
27
35
const endpointCacheSize = 100 ;
28
36
resolveEndpointDiscoveryConfig (
29
37
{
30
- ...mockInput ,
38
+ ...mockInput ( ) ,
31
39
endpointCacheSize,
32
40
} ,
33
41
{ endpointDiscoveryCommandCtor }
@@ -36,28 +44,30 @@ describe(resolveEndpointDiscoveryConfig.name, () => {
36
44
} ) ;
37
45
38
46
it ( "creates cache of size 1000 if endpointCacheSize not passed" , ( ) => {
39
- resolveEndpointDiscoveryConfig ( mockInput , { endpointDiscoveryCommandCtor } ) ;
47
+ resolveEndpointDiscoveryConfig ( mockInput ( ) , { endpointDiscoveryCommandCtor } ) ;
40
48
expect ( EndpointCache ) . toBeCalledWith ( 1000 ) ;
41
49
} ) ;
42
50
} ) ;
43
51
44
52
describe ( "endpointDiscoveryEnabled" , ( ) => {
45
53
it . each < boolean > ( [ false , true ] ) ( `sets to value passed in the config: %s` , async ( endpointDiscoveryEnabled ) => {
54
+ const input = mockInput ( ) ;
46
55
const resolvedConfig = resolveEndpointDiscoveryConfig (
47
56
{
48
- ...mockInput ,
57
+ ...input ,
49
58
endpointDiscoveryEnabled,
50
59
} ,
51
60
{ endpointDiscoveryCommandCtor }
52
61
) ;
53
62
await expect ( resolvedConfig . endpointDiscoveryEnabled ( ) ) . resolves . toBe ( endpointDiscoveryEnabled ) ;
54
- expect ( mockInput . endpointDiscoveryEnabledProvider ) . not . toHaveBeenCalled ( ) ;
63
+ expect ( input . endpointDiscoveryEnabledProvider ) . not . toHaveBeenCalled ( ) ;
55
64
expect ( resolvedConfig . isClientEndpointDiscoveryEnabled ) . toStrictEqual ( true ) ;
56
65
} ) ;
57
66
58
67
it ( `sets to endpointDiscoveryEnabledProvider if value is not passed` , ( ) => {
59
- const resolvedConfig = resolveEndpointDiscoveryConfig ( mockInput , { endpointDiscoveryCommandCtor } ) ;
60
- expect ( resolvedConfig . endpointDiscoveryEnabled ) . toBe ( mockInput . endpointDiscoveryEnabledProvider ) ;
68
+ const input = mockInput ( ) ;
69
+ const resolvedConfig = resolveEndpointDiscoveryConfig ( input , { endpointDiscoveryCommandCtor } ) ;
70
+ expect ( resolvedConfig . endpointDiscoveryEnabled ) . toBe ( input . endpointDiscoveryEnabledProvider ) ;
61
71
expect ( resolvedConfig . isClientEndpointDiscoveryEnabled ) . toStrictEqual ( false ) ;
62
72
} ) ;
63
73
} ) ;
0 commit comments