Repository navigation
Expand file tree
/
Copy pathgithub-installation.mock.ts
More file actions
62 lines (58 loc) · 2.31 KB
/
Copy pathgithub-installation.mock.ts
File metadata and controls
62 lines (58 loc) · 2.31 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
import { vi } from 'vitest'
/**
* Stand-in for `GitHubInstallationError` from `@/lib/oauth/github-installation`: same `name` and
* constructor `(message, status?, operation?)`.
*/
export class MockGitHubInstallationError extends Error {
constructor(
message: string,
readonly status?: number,
readonly operation?: string
) {
super(message)
this.name = 'GitHubInstallationError'
}
}
/**
* Controllable mock functions for `@/lib/oauth/github-installation`. Every function is a bare
* `vi.fn()` (binding parsing and configuration depend on zod and env, so tests set them).
*
* @example
* ```ts
* import { githubInstallationMockFns } from '@sim/testing/mocks/github-installation.mock'
*
* githubInstallationMockFns.mockParseGitHubInstallationBinding.mockReturnValue(binding)
* ```
*/
export const githubInstallationMockFns = {
mockGetGitHubInstallationConfiguration: vi.fn(),
mockParseGitHubInstallationBinding: vi.fn(),
mockListUserAdminGitHubInstallations: vi.fn(),
mockAssertGitHubInstallationActive: vi.fn(),
mockAssertGitHubInstallationRepositoryActive: vi.fn(),
mockVerifyGitHubInstallationBinding: vi.fn(),
mockResolveGitHubInstallationRepository: vi.fn(),
mockListGitHubInstallationRepositories: vi.fn(),
mockResolveGitHubInstallationAccessToken: vi.fn(),
}
const fns = githubInstallationMockFns
/**
* Static mock module for `@/lib/oauth/github-installation`.
*
* @example
* ```ts
* vi.mock('@/lib/oauth/github-installation', () => githubInstallationMock)
* ```
*/
export const githubInstallationMock = {
GitHubInstallationError: MockGitHubInstallationError,
getGitHubInstallationConfiguration: fns.mockGetGitHubInstallationConfiguration,
parseGitHubInstallationBinding: fns.mockParseGitHubInstallationBinding,
listUserAdminGitHubInstallations: fns.mockListUserAdminGitHubInstallations,
assertGitHubInstallationActive: fns.mockAssertGitHubInstallationActive,
assertGitHubInstallationRepositoryActive: fns.mockAssertGitHubInstallationRepositoryActive,
verifyGitHubInstallationBinding: fns.mockVerifyGitHubInstallationBinding,
resolveGitHubInstallationRepository: fns.mockResolveGitHubInstallationRepository,
listGitHubInstallationRepositories: fns.mockListGitHubInstallationRepositories,
resolveGitHubInstallationAccessToken: fns.mockResolveGitHubInstallationAccessToken,
}