@@ -9,35 +9,51 @@ import { GetParameterError, TransformParameterError } from '../../src/errors';
99import { toBase64 } from '@aws-sdk/util-base64-node' ;
1010
1111const encoder = new TextEncoder ( ) ;
12+ jest . mock ( '@aws-lambda-powertools/commons' , ( ) => ( {
13+ ...jest . requireActual ( '@aws-lambda-powertools/commons' ) ,
14+ addUserAgentMiddleware : jest . fn ( ) ,
15+ } ) ) ;
16+
17+ class TestProvider extends BaseProvider {
18+ public constructor ( ) {
19+ super ( {
20+ proto : class {
21+ #name = 'TestProvider' ;
22+
23+ public hello ( ) : string {
24+ return this . #name;
25+ }
26+ } ,
27+ } ) ;
28+ }
1229
13- describe ( 'Class: BaseProvider' , ( ) => {
14- afterEach ( ( ) => {
15- jest . clearAllMocks ( ) ;
16- } ) ;
17-
18- class TestProvider extends BaseProvider {
19- public _add ( key : string , value : ExpirableValue ) : void {
20- this . store . set ( key , value ) ;
21- }
30+ public _add ( key : string , value : ExpirableValue ) : void {
31+ this . store . set ( key , value ) ;
32+ }
2233
23- public _get ( _name : string ) : Promise < string > {
24- throw Error ( 'Not implemented.' ) ;
25- }
34+ public _get ( _name : string ) : Promise < string > {
35+ throw Error ( 'Not implemented.' ) ;
36+ }
2637
27- public _getKeyTest ( key : string ) : ExpirableValue | undefined {
28- return this . store . get ( key ) ;
29- }
38+ public _getKeyTest ( key : string ) : ExpirableValue | undefined {
39+ return this . store . get ( key ) ;
40+ }
3041
31- public _getMultiple (
32- _path : string
33- ) : Promise < Record < string , string | undefined > > {
34- throw Error ( 'Not implemented.' ) ;
35- }
42+ public _getMultiple (
43+ _path : string
44+ ) : Promise < Record < string , string | undefined > > {
45+ throw Error ( 'Not implemented.' ) ;
46+ }
3647
37- public _getStoreSize ( ) : number {
38- return this . store . size ;
39- }
48+ public _getStoreSize ( ) : number {
49+ return this . store . size ;
4050 }
51+ }
52+
53+ describe ( 'Class: BaseProvider' , ( ) => {
54+ afterEach ( ( ) => {
55+ jest . clearAllMocks ( ) ;
56+ } ) ;
4157
4258 describe ( 'Method: addToCache' , ( ) => {
4359 test ( 'when called with a value and maxAge equal to 0, it skips the cache entirely' , ( ) => {
@@ -581,18 +597,6 @@ describe('Class: BaseProvider', () => {
581597} ) ;
582598
583599describe ( 'Function: clearCaches' , ( ) => {
584- class TestProvider extends BaseProvider {
585- public _get ( _name : string ) : Promise < string > {
586- throw Error ( 'Not implemented.' ) ;
587- }
588-
589- public _getMultiple (
590- _path : string
591- ) : Promise < Record < string , string | undefined > > {
592- throw Error ( 'Not implemented.' ) ;
593- }
594- }
595-
596600 test ( 'when called, it clears all the caches' , ( ) => {
597601 // Prepare
598602 const provider1 = new TestProvider ( ) ;
0 commit comments