Skip to content
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

WIP: BREAKING CHANGE: evaluated nonbusinessdays #143

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/clockodo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,8 @@ describe("Clockodo (instance)", () => {
});
});

describe("getNonbusinessDays()", () => {
it("correctly builds getNonbusinessDays() request", async () => {
describe("getEvaluatedNonbusinessDays()", () => {
it("correctly builds getEvaluatedNonbusinessDays() request", async () => {
const nockScope = nock(CLOCKODO_API)
.get(
"/nonbusinessdays?" +
Expand All @@ -583,19 +583,19 @@ describe("Clockodo (instance)", () => {
)
.reply(200, {});

await clockodo.getNonbusinessDays({
await clockodo.getEvaluatedNonbusinessDays({
nonbusinessgroupsId: [123],
year: 2021,
});

nockScope.done();
});

it("throws an error when getNonbusinessDays() is missing param", async () => {
it("throws an error when getEvaluatedNonbusinessDays() is missing param", async () => {
expect.assertions(1);

return expect(
clockodo.getNonbusinessDays(
clockodo.getEvaluatedNonbusinessDays(
// @ts-expect-error Year is missing
{ nonbusinessgroupsId: 123 }
)
Expand Down
8 changes: 7 additions & 1 deletion src/clockodo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,12 @@ export class Clockodo {
}

async getNonbusinessDays(
params?: Params
): Promise<NonbusinessDaysReturnType> {
return this.api.get("/v2/nonbusinessdays", params);
}

async getEvaluatedNonbusinessDays(
params: Params<{
nonbusinessgroupsId?:
| NonbusinessGroup["id"]
Expand All @@ -411,7 +417,7 @@ export class Clockodo {
): Promise<NonbusinessDaysReturnType> {
REQUIRED.checkRequired(params, REQUIRED.GET_NONBUSINESS_DAYS);

return this.api.get("/nonbusinessdays", params);
return this.api.get("/v2/nonbusinessdays/evaluated", params);
}

async getAggregatesUsersMe(
Expand Down
4 changes: 2 additions & 2 deletions src/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ describe("Clockodo", () => {
});
});

describe("getNonbusinessGroups() / getNonbusinessDays()", () => {
describe("getNonbusinessGroups() / getEvaluatedNonbusinessDays()", () => {
it("returns expected data format", async () => {
const { nonbusinessgroups: nonbusinessGroups } =
await clockodo.getNonbusinessGroups();
Expand All @@ -352,7 +352,7 @@ describe("Clockodo", () => {
const [firstNonbusinessGroup] = nonbusinessGroups;

const { nonbusinessdays: nonbusinessDays } =
await clockodo.getNonbusinessDays({
await clockodo.getEvaluatedNonbusinessDays({
nonbusinessgroupsId: firstNonbusinessGroup.id,
year: 2021,
});
Expand Down
1 change: 1 addition & 0 deletions src/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export * from "./models/holidaysquota.mocks.js";
export * from "./models/lumpsumService.mocks.js";
export * from "./models/service.mocks.js";
export * from "./models/nonbusinessDay.mocks.js";
export * from "./models/nonbusinessGroup.mocks.js";
export * from "./models/overtimecarry.mocks.js";
export * from "./models/project.mocks.js";
// export * from "./models/service.mocks.js";
Expand Down
5 changes: 5 additions & 0 deletions src/models/nonbusinessDay.mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,17 @@ export const createNonbusinessDayMocks = ({
const name = faker.lorem.words();
const isHalfDay = faker.datatype.number({ min: 0, max: 10 }) > 8;

const periodic = faker.datatype.boolean();

return {
date: isoDateFromDateTime(dateTime),
id,
nonbusinessgroupsId: 0,
name,
halfDay: isHalfDay,
surchargeSpecial: faker.datatype.boolean(),
periodic,
differentPerYear: periodic ? faker.datatype.boolean() : false,
};
});
};
6 changes: 6 additions & 0 deletions src/models/nonbusinessDay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@ export type NonbusinessDay = {
name: string;
/** It is half a nonbusiness day */
halfDay: boolean;
/** It is a special nonbusiness day */
surchargeSpecial: boolean;
/** It is a recurring nonbusiness day */
periodic: boolean;
/** Varies from year per year */
differentPerYear: boolean;
};
15 changes: 15 additions & 0 deletions src/models/nonbusinessGroup.mocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { faker } from "@faker-js/faker";
import { NonbusinessGroup } from "./nonbusinessGroup.js";

export const createNonbusinessGroupMocks = ({
count = 1,
}: {
count?: number;
dateBetween?: readonly [Date, Date];
}) =>
Array.from({ length: count }, (_, index): NonbusinessGroup => {
return {
id: index,
name: faker.commerce.productName(),
};
});
Loading