|
| 1 | +import { Constants } from '../constants'; |
| 2 | +import type { |
| 3 | + Account, |
| 4 | + AccountNotifications, |
| 5 | + GitifyError, |
| 6 | + Hostname, |
| 7 | + Token, |
| 8 | +} from '../types'; |
| 9 | +import { |
| 10 | + mockEnterpriseNotifications, |
| 11 | + mockGitHubNotifications, |
| 12 | + mockSingleNotification, |
| 13 | +} from '../utils/api/__mocks__/response-mocks'; |
| 14 | +import { mockGitifyUser } from './user-mocks'; |
| 15 | + |
| 16 | +export const mockPersonalAccessTokenAccount: Account = { |
| 17 | + platform: 'GitHub Cloud', |
| 18 | + method: 'Personal Access Token', |
| 19 | + token: 'token-123-456' as Token, |
| 20 | + hostname: Constants.DEFAULT_AUTH_OPTIONS.hostname, |
| 21 | + user: mockGitifyUser, |
| 22 | + hasRequiredScopes: true, |
| 23 | +}; |
| 24 | + |
| 25 | +export const mockOAuthAccount: Account = { |
| 26 | + platform: 'GitHub Enterprise Server', |
| 27 | + method: 'OAuth App', |
| 28 | + token: '1234568790' as Token, |
| 29 | + hostname: 'github.gitify.io' as Hostname, |
| 30 | + user: mockGitifyUser, |
| 31 | + hasRequiredScopes: true, |
| 32 | +}; |
| 33 | + |
| 34 | +export const mockGitHubCloudAccount: Account = { |
| 35 | + platform: 'GitHub Cloud', |
| 36 | + method: 'Personal Access Token', |
| 37 | + token: 'token-123-456' as Token, |
| 38 | + hostname: Constants.DEFAULT_AUTH_OPTIONS.hostname, |
| 39 | + user: mockGitifyUser, |
| 40 | + version: 'latest', |
| 41 | + hasRequiredScopes: true, |
| 42 | +}; |
| 43 | + |
| 44 | +export const mockGitHubEnterpriseServerAccount: Account = { |
| 45 | + platform: 'GitHub Enterprise Server', |
| 46 | + method: 'Personal Access Token', |
| 47 | + token: '1234568790' as Token, |
| 48 | + hostname: 'github.gitify.io' as Hostname, |
| 49 | + user: mockGitifyUser, |
| 50 | + hasRequiredScopes: true, |
| 51 | +}; |
| 52 | + |
| 53 | +export const mockGitHubAppAccount: Account = { |
| 54 | + platform: 'GitHub Cloud', |
| 55 | + method: 'GitHub App', |
| 56 | + token: '987654321' as Token, |
| 57 | + hostname: Constants.DEFAULT_AUTH_OPTIONS.hostname, |
| 58 | + user: mockGitifyUser, |
| 59 | + hasRequiredScopes: true, |
| 60 | +}; |
| 61 | + |
| 62 | +export const mockAccountNotifications: AccountNotifications[] = [ |
| 63 | + { |
| 64 | + account: mockGitHubCloudAccount, |
| 65 | + notifications: mockGitHubNotifications, |
| 66 | + error: null, |
| 67 | + }, |
| 68 | + { |
| 69 | + account: mockGitHubEnterpriseServerAccount, |
| 70 | + notifications: mockEnterpriseNotifications, |
| 71 | + error: null, |
| 72 | + }, |
| 73 | +]; |
| 74 | + |
| 75 | +export const mockSingleAccountNotifications: AccountNotifications[] = [ |
| 76 | + { |
| 77 | + account: mockGitHubCloudAccount, |
| 78 | + notifications: [mockSingleNotification], |
| 79 | + error: null, |
| 80 | + }, |
| 81 | +]; |
| 82 | + |
| 83 | +export function mockAccountWithError(error: GitifyError): AccountNotifications { |
| 84 | + return { |
| 85 | + account: mockGitHubCloudAccount, |
| 86 | + notifications: [], |
| 87 | + error, |
| 88 | + }; |
| 89 | +} |
0 commit comments