11import 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' ;
33import * as testData from './testData.json' ;
44
55jest . mock ( '../src/edgekv/edgekv' , ( ) => ( {
66 EdgeKV : jest . fn ( ) ,
77} ) ) ;
88
9+ let logger : LDLogger ;
10+
911const sdkKey = 'test-sdk-key' ;
1012const flagKey1 = 'testFlag1' ;
1113const flagKey2 = 'testFlag2' ;
@@ -17,11 +19,17 @@ describe('init', () => {
1719
1820 describe ( 'init with Edge KV' , ( ) => {
1921 beforeAll ( async ( ) => {
20- ldClient = initWithEdgeKV ( { namespace : 'akamai-test' , group : 'Akamai' , sdkKey } ) ;
22+ ldClient = initWithEdgeKV ( { namespace : 'akamai-test' , group : 'Akamai' , sdkKey, options : { logger } } ) ;
2123 await ldClient . waitForInitialization ( ) ;
2224 } ) ;
2325
2426 beforeEach ( ( ) => {
27+ logger = {
28+ error : jest . fn ( ) ,
29+ warn : jest . fn ( ) ,
30+ info : jest . fn ( ) ,
31+ debug : jest . fn ( ) ,
32+ } ;
2533 jest
2634 . spyOn ( EdgeKVProvider . prototype , 'get' )
2735 . mockImplementation ( ( ) => Promise . resolve ( JSON . stringify ( testData ) ) ) ;
@@ -31,6 +39,12 @@ describe('init', () => {
3139 ldClient . close ( ) ;
3240 } ) ;
3341
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+
3448 describe ( 'flags' , ( ) => {
3549 it ( 'variation default' , async ( ) => {
3650 const value = await ldClient . variation ( flagKey1 , context , false ) ;
0 commit comments