From 0467eb9ccd16b1bcc8e2f9b6d4a0f230852340aa Mon Sep 17 00:00:00 2001 From: Dominik Sumer Date: Thu, 19 Oct 2023 15:11:38 +0200 Subject: [PATCH] adjusted mock creation --- src/models/overtimereduced.mocks.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/models/overtimereduced.mocks.ts b/src/models/overtimereduced.mocks.ts index 73908c1c..3f58abbf 100644 --- a/src/models/overtimereduced.mocks.ts +++ b/src/models/overtimereduced.mocks.ts @@ -2,19 +2,26 @@ import { faker } from "@faker-js/faker"; import { OvertimereducedRow } from "./overtimereduced.js"; import { isoDateFromDateTime } from "../lib/dateTime.js"; +type Options = { + count?: number; + hoursMinMax?: [number, number]; +}; + export const createOvertimereducedMocks = ({ count = 1, - usersId = 0, - usersIdAdded = 1, -}: { count?: number; usersId?: number; usersIdAdded?: number } = {}) => { + hoursMinMax = [0, 100], +}: Options = {}) => { return Array.from({ length: count }, (_, index): OvertimereducedRow => { return { id: index, - usersId, - usersIdAdded, + usersId: 0, + usersIdAdded: 1, dateAdded: isoDateFromDateTime(faker.date.past()), note: faker.datatype.boolean() ? faker.lorem.sentences(2) : null, - hours: faker.datatype.number({ min: 0, max: 100 }), + hours: faker.datatype.number({ + min: hoursMinMax[0], + max: hoursMinMax[1], + }), createdAfterEndOfMonth: faker.datatype.boolean(), }; });