1
1
import EdgeKVProvider from '../src/edgekv/edgeKVProvider' ;
2
- import { init as initWithEdgeKV , LDClient , LDContext } from '../src/index' ;
2
+ import { init as initWithEdgeKV , LDClient , LDContext , LDLogger } from '../src/index' ;
3
3
import * as testData from './testData.json' ;
4
4
5
5
jest . mock ( '../src/edgekv/edgekv' , ( ) => ( {
6
6
EdgeKV : jest . fn ( ) ,
7
7
} ) ) ;
8
8
9
+ let logger : LDLogger ;
10
+
9
11
const sdkKey = 'test-sdk-key' ;
10
12
const flagKey1 = 'testFlag1' ;
11
13
const flagKey2 = 'testFlag2' ;
@@ -17,11 +19,17 @@ describe('init', () => {
17
19
18
20
describe ( 'init with Edge KV' , ( ) => {
19
21
beforeAll ( async ( ) => {
20
- ldClient = initWithEdgeKV ( { namespace : 'akamai-test' , group : 'Akamai' , sdkKey } ) ;
22
+ ldClient = initWithEdgeKV ( { namespace : 'akamai-test' , group : 'Akamai' , sdkKey, options : { logger } } ) ;
21
23
await ldClient . waitForInitialization ( ) ;
22
24
} ) ;
23
25
24
26
beforeEach ( ( ) => {
27
+ logger = {
28
+ error : jest . fn ( ) ,
29
+ warn : jest . fn ( ) ,
30
+ info : jest . fn ( ) ,
31
+ debug : jest . fn ( ) ,
32
+ } ;
25
33
jest
26
34
. spyOn ( EdgeKVProvider . prototype , 'get' )
27
35
. mockImplementation ( ( ) => Promise . resolve ( JSON . stringify ( testData ) ) ) ;
@@ -31,6 +39,12 @@ describe('init', () => {
31
39
ldClient . close ( ) ;
32
40
} ) ;
33
41
42
+ it ( 'should not log a warning about initialization' , async ( ) => {
43
+ const spy = jest . spyOn ( logger , 'warn' ) ;
44
+ const value = await ldClient . variation ( flagKey1 , context , false ) ;
45
+ expect ( spy ) . not . toHaveBeenCalled ( ) ;
46
+ } )
47
+
34
48
describe ( 'flags' , ( ) => {
35
49
it ( 'variation default' , async ( ) => {
36
50
const value = await ldClient . variation ( flagKey1 , context , false ) ;
0 commit comments