Skip to content

Commit 509aa4c

Browse files
committed
Add test ensuring we are initialized
1 parent e8a7400 commit 509aa4c

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

packages/sdk/akamai-edgekv/__tests__/index.test.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
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';
33
import * as testData from './testData.json';
44

55
jest.mock('../src/edgekv/edgekv', () => ({
66
EdgeKV: jest.fn(),
77
}));
88

9+
let logger: LDLogger;
10+
911
const sdkKey = 'test-sdk-key';
1012
const flagKey1 = 'testFlag1';
1113
const 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

Comments
 (0)