Skip to content

Commit

Permalink
chore: Added setup listeners tests. Removed release-as config.
Browse files Browse the repository at this point in the history
  • Loading branch information
yusinto committed Dec 29, 2023
1 parent 56f1847 commit 46389a0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/sdk/react-native/src/provider/LDProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import LDProvider from './LDProvider';
import setupListeners from './setupListeners';

jest.mock('./setupListeners');
jest.mock('../ReactNativeLDClient', () => jest.fn());
jest.mock('../ReactNativeLDClient');

const TestApp = () => {
const ldClient = useLDClient();
Expand All @@ -21,7 +21,7 @@ const TestApp = () => {
);
};
describe('LDProvider', () => {
let ldc: any;
let ldc: ReactNativeLDClient;
let context: LDContext;
let mockSetupListeners = setupListeners as jest.Mock;

Expand Down
32 changes: 32 additions & 0 deletions packages/sdk/react-native/src/provider/setupListeners.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import ReactNativeLDClient from '../ReactNativeLDClient';
import setupListeners from './setupListeners';

import resetAllMocks = jest.resetAllMocks;

jest.mock('../ReactNativeLDClient');

describe('setupListeners', () => {
let ldc: ReactNativeLDClient;
let mockSetState: jest.Mock;

beforeEach(() => {
mockSetState = jest.fn();
ldc = new ReactNativeLDClient('mob-test-key');
});

afterEach(() => resetAllMocks());

test('change listener is setup', () => {
setupListeners(ldc, mockSetState);
expect(ldc.on).toHaveBeenCalledWith('change', expect.any(Function));
});

test('client is set on change event', () => {
setupListeners(ldc, mockSetState);

const changeHandler = (ldc.on as jest.Mock).mock.calls[0][1];
changeHandler();

expect(mockSetState).toHaveBeenCalledWith({ client: ldc });
});
});
8 changes: 2 additions & 6 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
{
"packages": {
"packages/shared/common": {},
"packages/shared/sdk-client": {
"bump-minor-pre-major": true
},
"packages/shared/sdk-client": {},
"packages/shared/sdk-server": {},
"packages/shared/sdk-server-edge": {},
"packages/shared/akamai-edgeworker-sdk": {},
"packages/sdk/cloudflare": {},
"packages/sdk/react-native": {
"bump-minor-pre-major": true
},
"packages/sdk/react-native": {},
"packages/sdk/server-node": {},
"packages/sdk/vercel": {
"extra-files": ["src/createPlatformInfo.ts"]
Expand Down

0 comments on commit 46389a0

Please sign in to comment.