Skip to content

Commit

Permalink
Merge branch 'development' into fix/DX-1565
Browse files Browse the repository at this point in the history
  • Loading branch information
Vikram Kalta authored and Vikram Kalta committed Nov 7, 2024
2 parents 818e13f + 00608e0 commit 1895cbb
Showing 1 changed file with 21 additions and 21 deletions.
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

0 comments on commit 1895cbb

Please sign in to comment.