-
Notifications
You must be signed in to change notification settings - Fork 289
Expand file tree
/
Copy pathnotifications-mocks.ts
More file actions
86 lines (80 loc) · 2.11 KB
/
Copy pathnotifications-mocks.ts
File metadata and controls
86 lines (80 loc) · 2.11 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import { Constants } from '../constants';
import type { AccountNotifications, Hostname } from '../types';
import type {
Notification,
Repository,
StateType,
Subject,
SubjectType,
} from '../typesGitHub';
import {
mockEnterpriseNotifications,
mockGitHubNotifications,
mockSingleNotification,
} from '../utils/api/__mocks__/response-mocks';
import {
mockGitHubCloudAccount,
mockGitHubEnterpriseServerAccount,
} from './account-mocks';
import { mockToken } from './state-mocks';
import { mockGitifyUser } from './user-mocks';
export function createMockSubject(mocks: {
title?: string;
type?: SubjectType;
state?: StateType;
}): Subject {
return {
title: mocks.title ?? 'Mock Subject',
type: mocks.type ?? ('Unknown' as SubjectType),
state: mocks.state ?? ('Unknown' as StateType),
url: null,
latest_comment_url: null,
};
}
export function createPartialMockNotification(
subject: Partial<Subject>,
repository?: Partial<Repository>,
): Notification {
const mockNotification: Partial<Notification> = {
account: {
method: 'Personal Access Token',
platform: 'GitHub Cloud',
hostname: Constants.GITHUB_API_BASE_URL as Hostname,
token: mockToken,
user: mockGitifyUser,
hasRequiredScopes: true,
},
subject: subject as Subject,
repository: repository as Repository,
};
return mockNotification as Notification;
}
export function createMockNotificationForRepoName(
id: string,
repoFullName: string | null,
): Notification {
return {
id,
repository: repoFullName ? { full_name: repoFullName } : null,
account: mockGitHubCloudAccount,
} as Notification;
}
export const mockAccountNotifications: AccountNotifications[] = [
{
account: mockGitHubCloudAccount,
notifications: mockGitHubNotifications,
error: null,
},
{
account: mockGitHubEnterpriseServerAccount,
notifications: mockEnterpriseNotifications,
error: null,
},
];
export const mockSingleAccountNotifications: AccountNotifications[] = [
{
account: mockGitHubCloudAccount,
notifications: [mockSingleNotification],
error: null,
},
];