-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
103a676
commit e959305
Showing
2 changed files
with
14 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
import { createInstance } from '@optimizely/react-sdk'; | ||
import { createInstance, setLogLevel } from '@optimizely/react-sdk'; | ||
|
||
const OPTIMIZELY_SDK_KEY = process.env.OPTIMIZELY_FULL_STACK_SDK_KEY; | ||
|
||
const optimizelyClient = createInstance({ | ||
sdkKey: OPTIMIZELY_SDK_KEY, | ||
}); | ||
const configureClient = () => { | ||
setLogLevel('error'); | ||
|
||
return createInstance({ | ||
sdkKey: OPTIMIZELY_SDK_KEY, | ||
}); | ||
}; | ||
|
||
const optimizelyClient = configureClient(); | ||
|
||
export default optimizelyClient; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
import { createInstance } from '@optimizely/react-sdk'; | ||
import { createInstance, setLogLevel } from '@optimizely/react-sdk'; | ||
import optimizelyClient from './optimizely'; | ||
|
||
jest.mock('@optimizely/react-sdk', () => ({ | ||
createInstance: jest.fn(() => 'mockedClient'), | ||
setLogLevel: jest.fn(), | ||
})); | ||
|
||
describe('optimizelyClient', () => { | ||
it('should create an Optimizely client instance with the correct SDK key', () => { | ||
it('should configure an Optimizely client instance with the correct SDK key', () => { | ||
expect(optimizelyClient).toBeDefined(); | ||
expect(setLogLevel).toHaveBeenCalledWith('error'); | ||
expect(createInstance).toHaveBeenCalledWith({ sdkKey: 'SDK Key' }); | ||
}); | ||
}); |