@@ -9,35 +9,51 @@ import { GetParameterError, TransformParameterError } from '../../src/errors';
9
9
import { toBase64 } from '@aws-sdk/util-base64-node' ;
10
10
11
11
const 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
+ }
12
29
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
+ }
22
33
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
+ }
26
37
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
+ }
30
41
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
+ }
36
47
37
- public _getStoreSize ( ) : number {
38
- return this . store . size ;
39
- }
48
+ public _getStoreSize ( ) : number {
49
+ return this . store . size ;
40
50
}
51
+ }
52
+
53
+ describe ( 'Class: BaseProvider' , ( ) => {
54
+ afterEach ( ( ) => {
55
+ jest . clearAllMocks ( ) ;
56
+ } ) ;
41
57
42
58
describe ( 'Method: addToCache' , ( ) => {
43
59
test ( 'when called with a value and maxAge equal to 0, it skips the cache entirely' , ( ) => {
@@ -581,18 +597,6 @@ describe('Class: BaseProvider', () => {
581
597
} ) ;
582
598
583
599
describe ( '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
-
596
600
test ( 'when called, it clears all the caches' , ( ) => {
597
601
// Prepare
598
602
const provider1 = new TestProvider ( ) ;
0 commit comments