@@ -8,11 +8,12 @@ import { ExpirableValue } from '../../src/base/ExpirableValue';
8
8
import { AppConfigProviderOptions } from '../../src/types/AppConfigProvider' ;
9
9
import {
10
10
AppConfigDataClient ,
11
- StartConfigurationSessionCommand ,
12
11
GetLatestConfigurationCommand ,
12
+ StartConfigurationSessionCommand ,
13
13
} from '@aws-sdk/client-appconfigdata' ;
14
14
import { Uint8ArrayBlobAdapter } from '@aws-sdk/util-stream' ;
15
15
import { mockClient } from 'aws-sdk-client-mock' ;
16
+ import * as UserAgentMiddleware from '@aws-lambda-powertools/commons/lib/userAgentMiddleware' ;
16
17
import 'aws-sdk-client-mock-jest' ;
17
18
18
19
describe ( 'Class: AppConfigProvider' , ( ) => {
@@ -34,6 +35,11 @@ describe('Class: AppConfigProvider', () => {
34
35
environment : 'MyAppProdEnv' ,
35
36
} ;
36
37
38
+ const userAgentSpy = jest . spyOn (
39
+ UserAgentMiddleware ,
40
+ 'addUserAgentMiddleware'
41
+ ) ;
42
+
37
43
// Act
38
44
const provider = new AppConfigProvider ( options ) ;
39
45
@@ -43,6 +49,8 @@ describe('Class: AppConfigProvider', () => {
43
49
serviceId : 'AppConfigData' ,
44
50
} )
45
51
) ;
52
+
53
+ expect ( userAgentSpy ) . toHaveBeenCalled ( ) ;
46
54
} ) ;
47
55
48
56
test ( 'when the user provides a client config in the options, the class instantiates a new client with client config options' , async ( ) => {
@@ -55,6 +63,11 @@ describe('Class: AppConfigProvider', () => {
55
63
} ,
56
64
} ;
57
65
66
+ const userAgentSpy = jest . spyOn (
67
+ UserAgentMiddleware ,
68
+ 'addUserAgentMiddleware'
69
+ ) ;
70
+
58
71
// Act
59
72
const provider = new AppConfigProvider ( options ) ;
60
73
@@ -64,6 +77,8 @@ describe('Class: AppConfigProvider', () => {
64
77
serviceId : 'with-client-config' ,
65
78
} )
66
79
) ;
80
+
81
+ expect ( userAgentSpy ) . toHaveBeenCalled ( ) ;
67
82
} ) ;
68
83
69
84
test ( 'when the user provides an SDK client in the options, the class instantiates with it' , async ( ) => {
@@ -78,6 +93,11 @@ describe('Class: AppConfigProvider', () => {
78
93
awsSdkV3Client : awsSdkV3Client ,
79
94
} ;
80
95
96
+ const userAgentSpy = jest . spyOn (
97
+ UserAgentMiddleware ,
98
+ 'addUserAgentMiddleware'
99
+ ) ;
100
+
81
101
// Act
82
102
const provider = new AppConfigProvider ( options ) ;
83
103
@@ -87,6 +107,8 @@ describe('Class: AppConfigProvider', () => {
87
107
serviceId : 'with-custom-sdk-client' ,
88
108
} )
89
109
) ;
110
+
111
+ expect ( userAgentSpy ) . toHaveBeenCalledWith ( awsSdkV3Client , 'parameters' ) ;
90
112
} ) ;
91
113
92
114
test ( 'when the user provides NOT an SDK client in the options, it throws an error' , async ( ) => {
@@ -187,6 +209,7 @@ describe('Class: AppConfigProvider', () => {
187
209
public _addToStore ( key : string , value : string ) : void {
188
210
this . configurationTokenStore . set ( key , value ) ;
189
211
}
212
+
190
213
public _storeHas ( key : string ) : boolean {
191
214
return this . configurationTokenStore . has ( key ) ;
192
215
}
0 commit comments