Skip to content

Add singleSync tests for shared client. - #134

Merged
emmaz90 merged 3 commits into
single-syncfrom
ssync-shared-client
Jun 15, 2022
Merged

Add singleSync tests for shared client. #134
emmaz90 merged 3 commits into
single-syncfrom
ssync-shared-client

Conversation

@emmaz90

@emmaz90 emmaz90 commented Jun 15, 2022

Copy link
Copy Markdown
Contributor

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

// Mocked storageManager
const storageManagerMock = {
splits: {
getSplit: (name: string) => STORED_SPLITS[name],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@emmaz90
emmaz90 merged commit fc3c5c8 into single-sync Jun 15, 2022
@emmaz90
emmaz90 deleted the ssync-shared-client branch June 15, 2022 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants