Add singleSync tests for shared client. - #134
Conversation
…on if singleSync is enabled
| // Mocked storageManager | ||
| const storageManagerMock = { | ||
| splits: { | ||
| getSplit: (name: string) => STORED_SPLITS[name], |
There was a problem hiding this comment.
I think we don't need to mock this method. Check if you can remove it, and also STORED_SPLITS, ALWAYS_OFF_SPLIT and ALWAYS_OFF_SPLIT
| isRunning: jest.fn() | ||
| }; | ||
| // @ts-ignore | ||
| const pollingSyncManager = syncManagerOnlineFactory(() => pollingManagerMock)({ settings }); |
There was a problem hiding this comment.
I see that we are duplicating same asserts with 2 syncManager instances: const pollingSyncManager = syncManagerOnlineFactory(() => pollingManagerMock)({ settings }); and const pushingSyncManager = syncManagerOnlineFactory(() => pollingManagerMock, () => pushManagerMock)({ settings });
I would have only one:
const syncManager = syncManagerOnlineFactory(() => pollingManagerMock, pushManagerFactoryMock)({ settings });
where pushManagerFactoryMock is a Jest.fn mock you can use to assert that the pushManager is not created when singleSync is false
Javascript commons library
What did you accomplish?
Add singleSync tests for shared client.
Avoid pushManager instantiation if singleSync is enabled
How do we test the changes introduced in this PR?
Unit tests included
Extra Notes