Skip to content

Back Merge #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 6, 2024
Merged
42 changes: 21 additions & 21 deletions test/unit/synchronization.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,62 +29,62 @@ describe('Synchronization function', () => {
it('should have valid init and environment params as req params when no request params is passed', async () => {
await await synchronization(httpClient({}));
expect(getDataMock.mock.calls[0][1]).toBe('/sync');
expect(getDataMock.mock.calls[0][2].params).toHaveProperty('init');
expect(getDataMock.mock.calls[0][2].params).toEqual({ init: true });
expect(getDataMock.mock.calls[0][2].params.params).toHaveProperty('init');
expect(getDataMock.mock.calls[0][2].params.params).toEqual({ init: true });
});

it('should have only pagination_token param when sync is called with pagination_token.', async () => {
await syncCall({ paginationToken: '<page_tkn>' });
expect(getDataMock.mock.calls[0][1]).toBe('/sync');
expect(getDataMock.mock.calls[0][2].params).not.toHaveProperty('init');
expect(getDataMock.mock.calls[0][2].params).not.toHaveProperty('environment');
expect(getDataMock.mock.calls[0][2].params).toHaveProperty('pagination_token');
expect(getDataMock.mock.calls[0][2].params).toEqual({ pagination_token: '<page_tkn>' });
expect(getDataMock.mock.calls[0][2].params.params).toHaveProperty('pagination_token');
expect(getDataMock.mock.calls[0][2].params.params).toEqual({ pagination_token: '<page_tkn>' });
});
it('should have only sync_token param when sync is called with sync_token.', async () => {
await syncCall({ syncToken: '<sync_tkn>' });
expect(getDataMock.mock.calls[0][1]).toBe('/sync');
expect(getDataMock.mock.calls[0][2].params).not.toHaveProperty('init');
expect(getDataMock.mock.calls[0][2].params).not.toHaveProperty('environment');
expect(getDataMock.mock.calls[0][2].params).toHaveProperty('sync_token');
expect(getDataMock.mock.calls[0][2].params).toEqual({ sync_token: '<sync_tkn>' });
expect(getDataMock.mock.calls[0][2].params.params).toHaveProperty('sync_token');
expect(getDataMock.mock.calls[0][2].params.params).toEqual({ sync_token: '<sync_tkn>' });
});
it('should have valid content_type_uid when content_type_uid is passed as param', async () => {
await syncCall({ contentTypeUid: 'session' });
expect(getDataMock.mock.calls[0][1]).toBe('/sync');
expect(getDataMock.mock.calls[0][2].params).toHaveProperty('init');
expect(getDataMock.mock.calls[0][2].params).toHaveProperty('content_type_uid');
expect(getDataMock.mock.calls[0][2].params).toEqual({
expect(getDataMock.mock.calls[0][2].params.params).toHaveProperty('init');
expect(getDataMock.mock.calls[0][2].params.params).toHaveProperty('content_type_uid');
expect(getDataMock.mock.calls[0][2].params.params).toEqual({
init: true,
content_type_uid: 'session',
});
});
it('should have valid locale when a locale is passed as param', async () => {
await syncCall({ locale: LOCALE });
expect(getDataMock.mock.calls[0][1]).toBe('/sync');
expect(getDataMock.mock.calls[0][2].params).toHaveProperty('init');
expect(getDataMock.mock.calls[0][2].params).toHaveProperty('locale');
expect(getDataMock.mock.calls[0][2].params).toEqual({
expect(getDataMock.mock.calls[0][2].params.params).toHaveProperty('init');
expect(getDataMock.mock.calls[0][2].params.params).toHaveProperty('locale');
expect(getDataMock.mock.calls[0][2].params.params).toEqual({
init: true,
locale: LOCALE,
});
});
it('should have valid date structure and other required params when start_date is passed as param', async () => {
await syncCall({ startDate: '2018-10-22' });
expect(getDataMock.mock.calls[0][1]).toBe('/sync');
expect(getDataMock.mock.calls[0][2].params).toHaveProperty('init');
expect(getDataMock.mock.calls[0][2].params).toHaveProperty('start_date');
expect(getDataMock.mock.calls[0][2].params).toEqual({
expect(getDataMock.mock.calls[0][2].params.params).toHaveProperty('init');
expect(getDataMock.mock.calls[0][2].params.params).toHaveProperty('start_date');
expect(getDataMock.mock.calls[0][2].params.params).toEqual({
init: true,
start_date: '2018-10-22',
});
});
it('should have valid publish_type when type is passed as param', async () => {
await syncCall({ type: [PublishType.ENTRY_PUBLISHED] });
expect(getDataMock.mock.calls[0][1]).toBe('/sync');
expect(getDataMock.mock.calls[0][2].params).toHaveProperty('init');
expect(getDataMock.mock.calls[0][2].params).toHaveProperty('type');
expect(getDataMock.mock.calls[0][2].params).toEqual({
expect(getDataMock.mock.calls[0][2].params.params).toHaveProperty('init');
expect(getDataMock.mock.calls[0][2].params.params).toHaveProperty('type');
expect(getDataMock.mock.calls[0][2].params.params).toEqual({
init: true,
type: 'entry_published',
});
Expand All @@ -96,9 +96,9 @@ describe('Synchronization function', () => {
type: [PublishType.ENTRY_PUBLISHED, PublishType.CONTENT_TYPE_DELETED],
});
expect(getDataMock.mock.calls[0][1]).toBe('/sync');
expect(getDataMock.mock.calls[0][2].params).toHaveProperty('init');
expect(getDataMock.mock.calls[0][2].params).toHaveProperty('type');
expect(getDataMock.mock.calls[0][2].params).toEqual({
expect(getDataMock.mock.calls[0][2].params.params).toHaveProperty('init');
expect(getDataMock.mock.calls[0][2].params.params).toHaveProperty('type');
expect(getDataMock.mock.calls[0][2].params.params).toEqual({
init: true,
start_date: '2018-10-22',
locale: 'en-us',
Expand Down
Loading