@@ -8,11 +8,12 @@ import { ExpirableValue } from '../../src/base/ExpirableValue';
88import { AppConfigProviderOptions } from '../../src/types/AppConfigProvider' ;
99import {
1010 AppConfigDataClient ,
11- StartConfigurationSessionCommand ,
1211 GetLatestConfigurationCommand ,
12+ StartConfigurationSessionCommand ,
1313} from '@aws-sdk/client-appconfigdata' ;
1414import { Uint8ArrayBlobAdapter } from '@aws-sdk/util-stream' ;
1515import { mockClient } from 'aws-sdk-client-mock' ;
16+ import * as UserAgentMiddleware from '@aws-lambda-powertools/commons/lib/userAgentMiddleware' ;
1617import 'aws-sdk-client-mock-jest' ;
1718
1819describe ( 'Class: AppConfigProvider' , ( ) => {
@@ -34,6 +35,11 @@ describe('Class: AppConfigProvider', () => {
3435 environment : 'MyAppProdEnv' ,
3536 } ;
3637
38+ const userAgentSpy = jest . spyOn (
39+ UserAgentMiddleware ,
40+ 'addUserAgentMiddleware'
41+ ) ;
42+
3743 // Act
3844 const provider = new AppConfigProvider ( options ) ;
3945
@@ -43,6 +49,8 @@ describe('Class: AppConfigProvider', () => {
4349 serviceId : 'AppConfigData' ,
4450 } )
4551 ) ;
52+
53+ expect ( userAgentSpy ) . toHaveBeenCalled ( ) ;
4654 } ) ;
4755
4856 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', () => {
5563 } ,
5664 } ;
5765
66+ const userAgentSpy = jest . spyOn (
67+ UserAgentMiddleware ,
68+ 'addUserAgentMiddleware'
69+ ) ;
70+
5871 // Act
5972 const provider = new AppConfigProvider ( options ) ;
6073
@@ -64,6 +77,8 @@ describe('Class: AppConfigProvider', () => {
6477 serviceId : 'with-client-config' ,
6578 } )
6679 ) ;
80+
81+ expect ( userAgentSpy ) . toHaveBeenCalled ( ) ;
6782 } ) ;
6883
6984 test ( 'when the user provides an SDK client in the options, the class instantiates with it' , async ( ) => {
@@ -78,6 +93,11 @@ describe('Class: AppConfigProvider', () => {
7893 awsSdkV3Client : awsSdkV3Client ,
7994 } ;
8095
96+ const userAgentSpy = jest . spyOn (
97+ UserAgentMiddleware ,
98+ 'addUserAgentMiddleware'
99+ ) ;
100+
81101 // Act
82102 const provider = new AppConfigProvider ( options ) ;
83103
@@ -87,6 +107,8 @@ describe('Class: AppConfigProvider', () => {
87107 serviceId : 'with-custom-sdk-client' ,
88108 } )
89109 ) ;
110+
111+ expect ( userAgentSpy ) . toHaveBeenCalledWith ( awsSdkV3Client , 'parameters' ) ;
90112 } ) ;
91113
92114 test ( 'when the user provides NOT an SDK client in the options, it throws an error' , async ( ) => {
@@ -187,6 +209,7 @@ describe('Class: AppConfigProvider', () => {
187209 public _addToStore ( key : string , value : string ) : void {
188210 this . configurationTokenStore . set ( key , value ) ;
189211 }
212+
190213 public _storeHas ( key : string ) : boolean {
191214 return this . configurationTokenStore . has ( key ) ;
192215 }
0 commit comments