Skip to content

Commit 8bdcd48

Browse files
committed
fix: align handler types with GitifyNotification/GitifySubject architecture
Update handlers and tests to use the camelCase GitifyNotification and GitifySubject types instead of raw snake_case GitHub API types.
1 parent 619a3cf commit 8bdcd48

25 files changed

+371
-743
lines changed

src/__mocks__/partial-mocks.ts

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
import { Constants } from '../constants';
2-
import type { Hostname, Link } from '../types';
3-
import type { Notification, Repository, Subject, User } from '../typesGitHub';
2+
import type {
3+
GitifyNotification,
4+
GitifyNotificationUser,
5+
GitifyRepository,
6+
GitifySubject,
7+
Hostname,
8+
Link,
9+
} from '../types';
10+
import type { User } from '../typesGitHub';
411
import { mockToken } from './state-mocks';
512
import { mockGitifyUser } from './user-mocks';
613

714
export function partialMockNotification(
8-
subject: Partial<Subject>,
9-
repository?: Partial<Repository>,
10-
): Notification {
11-
const mockNotification: Partial<Notification> = {
15+
subject: Partial<GitifySubject>,
16+
repository?: Partial<GitifyRepository>,
17+
): GitifyNotification {
18+
const mockNotification: Partial<GitifyNotification> = {
1219
account: {
1320
method: 'Personal Access Token',
1421
platform: 'GitHub Cloud',
@@ -17,14 +24,25 @@ export function partialMockNotification(
1724
user: mockGitifyUser,
1825
hasRequiredScopes: true,
1926
},
20-
subject: subject as Subject,
21-
repository: repository as Repository,
27+
subject: subject as GitifySubject,
28+
repository: repository as GitifyRepository,
2229
};
2330

24-
return mockNotification as Notification;
31+
return mockNotification as GitifyNotification;
2532
}
2633

27-
export function partialMockUser(login: string): User {
34+
export function partialMockUser(login: string): GitifyNotificationUser {
35+
const mockUser: Partial<GitifyNotificationUser> = {
36+
login: login,
37+
htmlUrl: `https://github.com/${login}` as Link,
38+
avatarUrl: 'https://avatars.githubusercontent.com/u/583231?v=4' as Link,
39+
type: 'User',
40+
};
41+
42+
return mockUser as GitifyNotificationUser;
43+
}
44+
45+
export function partialMockRawUser(login: string): User {
2846
const mockUser: Partial<User> = {
2947
login: login,
3048
html_url: `https://github.com/${login}` as Link,

0 commit comments

Comments
 (0)