-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Added setup listeners tests. Removed release-as config.
- Loading branch information
Showing
3 changed files
with
36 additions
and
8 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
32 changes: 32 additions & 0 deletions
32
packages/sdk/react-native/src/provider/setupListeners.test.ts
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 |
---|---|---|
@@ -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 }); | ||
}); | ||
}); |
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