-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.test.ts
More file actions
40 lines (31 loc) · 1.36 KB
/
utils.test.ts
File metadata and controls
40 lines (31 loc) · 1.36 KB
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
31
32
33
34
35
36
37
38
39
40
import { ObjectId } from 'mongodb';
import { ProjectDBScheme, GroupedEventDBScheme } from '@hawk.so/types';
import { getEventUrl } from '../src/templates/utils';
const project = {
_id: new ObjectId('5d206f7f9aaf7c0071d64596'),
token: 'project-token',
name: 'Project',
workspaceId: new ObjectId('5d206f7f9aaf7c0071d64596'),
uidAdded: new ObjectId('5d206f7f9aaf7c0071d64596'),
notifications: [],
} as ProjectDBScheme;
const event = {
_id: new ObjectId('5d206f7f9aaf7c0071d64597'),
payload: { title: 'Error' },
} as unknown as GroupedEventDBScheme;
const host = 'https://garage.hawk.so';
describe('getEventUrl', () => {
it('should return base URL with trailing slash when no repetitionId', () => {
const url = getEventUrl(host, project, event);
expect(url).toBe(`${host}/project/${project._id}/event/${event._id}/`);
});
it('should return base URL with trailing slash when repetitionId is null', () => {
const url = getEventUrl(host, project, event, null);
expect(url).toBe(`${host}/project/${project._id}/event/${event._id}/`);
});
it('should append repetitionId and /overview when repetitionId is provided', () => {
const repetitionId = '5d206f7f9aaf7c0071d64599';
const url = getEventUrl(host, project, event, repetitionId);
expect(url).toBe(`${host}/project/${project._id}/event/${event._id}/${repetitionId}/overview`);
});
});