mirror your GitHub repos to tangled.org automatically
1

Configure Feed

Select the types of activity you want to include in your feed.

1import { describe, expect, it, vi } from 'vitest' 2import { userAdministersInstallation } from '../../server/utils/github-app' 3import type { UserOctokit } from '../../server/utils/github-app' 4 5function octokitReturning(ids: number[]): UserOctokit { 6 const request = vi.fn<() => Promise<{ data: { installations: { id: number }[] } }>>( 7 async () => ({ data: { installations: ids.map(id => ({ id })) } }), 8 ) 9 // eslint-disable-next-line ts/no-unsafe-type-assertion -- only `request` is exercised 10 return { request } as unknown as UserOctokit 11} 12 13describe('userAdministersInstallation', () => { 14 it('returns true when the installation is in the user list', async () => { 15 const octokit = octokitReturning([10, 137556633, 42]) 16 expect(await userAdministersInstallation(octokit, 137556633)).toBe(true) 17 }) 18 19 it('returns false when the installation is absent', async () => { 20 const octokit = octokitReturning([10, 42]) 21 expect(await userAdministersInstallation(octokit, 137556633)).toBe(false) 22 }) 23 24 it('returns false for an empty installation list', async () => { 25 const octokit = octokitReturning([]) 26 expect(await userAdministersInstallation(octokit, 1)).toBe(false) 27 }) 28})