-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathtest.event.util.ts
More file actions
30 lines (27 loc) · 994 Bytes
/
test.event.util.ts
File metadata and controls
30 lines (27 loc) · 994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { faker } from "@faker-js/faker";
import { Origin, Priorities } from "@core/constants/core.constants";
import dayjs from "@core/util/date/dayjs";
import { Schema_DraftEvent } from "@web/common/schemas/events/draft.event.schemas";
import { Schema_WebEvent } from "@web/common/schemas/events/web.event.schemas";
/**
* These utils focus on generating web-specific schemas.
* For generating API-compatible events, see utils in `@core`
*/
export const createWebEvent = (
overrides: Partial<Schema_WebEvent> = {},
): Schema_WebEvent => {
const start = faker.date.future();
const end = dayjs(start).add(1, "hour");
return {
_id: faker.string.uuid(),
origin: Origin.COMPASS,
title: faker.lorem.sentence(),
description: faker.lorem.paragraph(),
startDate: start.toISOString(),
endDate: end.toISOString(),
priority: faker.helpers.arrayElement(Object.values(Priorities)),
recurrence: undefined,
user: faker.string.uuid(),
...overrides,
};
};