Skip to content

Commit

Permalink
Merge pull request #12 from launchdarkly/eb/ch59406-ch57883-ch57985/u…
Browse files Browse the repository at this point in the history
…pdate-common-sdk

use latest JS SDK release, add wrapper properties
  • Loading branch information
eli-darkly authored Dec 16, 2019
2 parents af62085 + 8820703 commit 761a913
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 21 deletions.
32 changes: 16 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"typescript": "^3.6.2"
},
"dependencies": {
"launchdarkly-js-client-sdk": "2.15.1",
"launchdarkly-js-client-sdk": "2.16.0",
"lodash.camelcase": "^4.3.0",
"uuid": "^3.3.2"
},
Expand Down
9 changes: 7 additions & 2 deletions src/initLDClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ jest.mock('launchdarkly-js-client-sdk', () => {
import { initialize, LDClient, LDOptions, LDUser } from 'launchdarkly-js-client-sdk';
import { defaultReactOptions, LDReactOptions } from './types';
import initLDClient from './initLDClient';
import * as packageJson from '../package.json';

const ldClientInitialize = initialize as jest.Mock;

const clientSideID = 'deadbeef';
const defaultUser: LDUser = { key: 'abcdef' };
const options: LDOptions = { bootstrap: 'localStorage' };
const options: LDOptions = { bootstrap: 'localStorage', wrapperName: 'React', wrapperVersion: packageJson.version };
const flags = { 'test-flag': false, 'another-test-flag': true };

describe('initLDClient', () => {
Expand All @@ -41,7 +42,11 @@ describe('initLDClient', () => {
const anonUser: LDUser = { anonymous: true };
await initLDClient(clientSideID);

expect(ldClientInitialize.mock.calls[0]).toEqual([clientSideID, anonUser, undefined]);
expect(ldClientInitialize.mock.calls[0]).toEqual([
clientSideID,
anonUser,
{ wrapperName: 'React', wrapperVersion: packageJson.version },
]);
expect(mockLDClient.variation).toHaveBeenCalledTimes(0);
});

Expand Down
4 changes: 3 additions & 1 deletion src/initLDClient.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { initialize as ldClientInitialize, LDClient, LDFlagSet, LDOptions, LDUser } from 'launchdarkly-js-client-sdk';
import { AllFlagsLDClient, defaultReactOptions, LDReactOptions } from './types';
import { camelCaseKeys } from './utils';
import * as packageJson from '../package.json';

/**
* Internal function to initialize the `LDClient`.
Expand All @@ -20,7 +21,8 @@ const initLDClient = async (
options?: LDOptions,
targetFlags?: LDFlagSet,
): Promise<AllFlagsLDClient> => {
const ldClient = ldClientInitialize(clientSideID, user, options);
const allOptions = { wrapperName: 'React', wrapperVersion: packageJson.version, ...options };
const ldClient = ldClientInitialize(clientSideID, user, allOptions);

return new Promise<AllFlagsLDClient>(resolve => {
ldClient.on('ready', () => {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"noImplicitAny": true,
"strictNullChecks": true,
"jsx": "react",
"esModuleInterop": true
"esModuleInterop": true,
"resolveJsonModule": true,
},
"files": [
"./node_modules/@testing-library/jest-dom/extend-expect.d.ts"
Expand Down

0 comments on commit 761a913

Please sign in to comment.