diff --git a/README.md b/README.md index 8ab1abe..c23bef4 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ module.exports = { ## Usage Use the only 3 apis for test cases: -* `mockFlags(flags: LDFlagSet)`: mock flags at the start of each test case. +`mockFlags(flags: LDFlagSet)`: mock flags at the start of each test case. * `ldClientMock`: a jest mock of the [ldClient](https://launchdarkly.github.io/js-client-sdk/interfaces/_launchdarkly_js_client_sdk_.ldclient.html). All methods of this object are jest mocks. diff --git a/src/index.test.ts b/src/index.test.ts index 38260ac..a6dccd1 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -25,6 +25,17 @@ describe('main', () => { expect(current['dev-test-flag']).toBeTruthy() }) + test('mock option without case formatting correctly', () => { + mockFlags({ DEV_test_Flag: true }) + + const { + result: { current }, + } = renderHook(() => useFlags()) + + expect(current.DEV_test_Flag).toBeTruthy() + expect(current['DEV_test_Flag']).toBeTruthy() + }) + test('mock asyncWithLDProvider correctly', () => { expect(asyncWithLDProvider).toBeDefined() }) diff --git a/src/index.ts b/src/index.ts index d85119e..c8917f3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -61,6 +61,7 @@ export const mockFlags = (flags: LDFlagSet) => { const camel = camelCase(k) result[kebab] = flags[k] result[camel] = flags[k] + result[k] = flags[k] }) return result })