Skip to content

Commit

Permalink
chore: add test for getOpenFeatureProvider()
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathannorris committed Jan 26, 2024
1 parent a0e38e7 commit 251d872
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 11 additions & 7 deletions sdk/nodejs/__tests__/initialize.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
DevCycleClient,
DevCycleCloudClient,
initializeDevCycle,
} from '../src/index'
import { DevCycleCloudClient, initializeDevCycle } from '../src/index'

jest.mock('../src/bucketing')
jest.mock('@devcycle/config-manager')
Expand All @@ -12,13 +8,21 @@ describe('NodeJS SDK Initialize', () => {
jest.clearAllMocks()
})

it('sucessfully calls initialize with no options', async () => {
const client: DevCycleClient = await initializeDevCycle(
it('successfully calls initialize with no options', async () => {
const client = await initializeDevCycle(
'dvc_server_token',
).onClientInitialized()
expect(client).toBeDefined()
})

it('successfully creates a OpenFeature provider', async () => {
const provider = await initializeDevCycle(
'dvc_server_token',
).getOpenFeatureProvider()
expect(provider).toBeDefined()
expect(provider.status).toBe('READY')
})

it('fails to initialize in Local Bucketing mode when no token is provided', () => {
expect(() =>
initializeDevCycle(undefined as unknown as string),
Expand Down
2 changes: 2 additions & 0 deletions sdk/nodejs/src/__mocks__/bucketing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export const importBucketingLib = async (): Promise<void> => {
.mockReturnValue(JSON.stringify(testVariable)),
variableForUser_PB: jest.fn().mockReturnValue(buffer),
VariableType,
initEventQueue: jest.fn(),
flushEventQueue: jest.fn(),
}),
)
}
Expand Down

0 comments on commit 251d872

Please sign in to comment.