Skip to content

Commit

Permalink
refactor timeplanning endpoint to use new response builder and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tomi-timetac committed Feb 11, 2021
1 parent 348ed07 commit 73f50c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { ServerCommunicationEndpoint } from './serverCommunication';
import { TasksEndpoint } from './tasks';
import { TeamMembersEndpoint } from './teamMembers';
import { TeamsEndpoint } from './teams';
import { TimePlanningsEndpoint } from './timeplannings';
import { TimesheetAccountingsEndpoint } from './timesheetAccountings';
import { TimeTrackingsEndpoint } from './timetrackings';
import { TimePlanningsEndpoint } from './timeplannings';
import { TodoTasksEndpoint } from './todoTasks';
import { UsersEndpoint } from './users';
import { UserStatusOverviewsEndpoint } from './userStatusOverview';
Expand All @@ -38,9 +38,9 @@ export { ServerCommunication } from './serverCommunication/types';
export { Task, TaskCreate } from './tasks/types';
export { TeamMember } from './teamMembers/types';
export { Team } from './teams/types';
export { TimePlanning } from './timeplannings/types';
export { TimesheetAccounting } from './timesheetAccountings/types';
export { StartTimeTrackingData, StopTimeTrackingData, TimeTracking, TimeTrackingCreate } from './timetrackings/types';
export { TimePlanning } from './timeplannings/types';
export { TodoTask, TodoTaskCreate } from './todoTasks/types';
export { User } from './users/types';
export { UserStatusOverview } from './userStatusOverview/types';
Expand Down
10 changes: 4 additions & 6 deletions src/timeplannings/timePlannings.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from 'axios';
import AxiosMockAdapter from 'axios-mock-adapter';

import { RequestParams } from '../utils/params/requestParams';
import { RequestParamsBuilder } from '../utils/params/requestParams';
import { TimePlanningsEndpoint } from './index';
import { TimePlanning } from './types';

Expand Down Expand Up @@ -39,15 +39,13 @@ describe('TimePlannings', () => {

test('read with RequestParams', async () => {
mock.onGet(readPath, { params: { user_id: '1', _op__user_id: 'eq' } }).reply(200, { Success: true, NumResults: 1, Results: [{}] });
result = timePlannings.read(new RequestParams<TimePlanning>().eq('user_id', 1));
result = timePlannings.read(new RequestParamsBuilder<TimePlanning>().eq('user_id', 1).build());
await result.then((result) => expect(result).toStrictEqual([{}]));

mock.reset();

mock
.onGet(readPath, { params: { user_id: '1', _op__user_id: 'eq', _op__date: 'gteq' } })
.onGet(readPath, { params: { user_id: '1', _op__user_id: 'eq', start_date: '2020-01-01', _op__start_date: 'gteq' } })
.reply(200, { Success: true, NumResults: 1, Results: [{}] });
result = timePlannings.read(new RequestParams<TimePlanning>().eq('user_id', 1));
result = timePlannings.read(new RequestParamsBuilder<TimePlanning>().eq('user_id', 1).gteq('start_date', '2020-01-01').build());
await result.then((result) => expect(result).toStrictEqual([{}]));
});

Expand Down

0 comments on commit 73f50c3

Please sign in to comment.