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(async () => ({ data: { installations: ids.map(id => ({ id })) } })) 7 // eslint-disable-next-line ts/no-unsafe-type-assertion -- only `request` is exercised 8 return { request } as unknown as UserOctokit 9} 10 11describe('userAdministersInstallation', () => { 12 it('returns true when the installation is in the user list', async () => { 13 const octokit = octokitReturning([10, 137556633, 42]) 14 expect(await userAdministersInstallation(octokit, 137556633)).toBe(true) 15 }) 16 17 it('returns false when the installation is absent', async () => { 18 const octokit = octokitReturning([10, 42]) 19 expect(await userAdministersInstallation(octokit, 137556633)).toBe(false) 20 }) 21 22 it('returns false for an empty installation list', async () => { 23 const octokit = octokitReturning([]) 24 expect(await userAdministersInstallation(octokit, 1)).toBe(false) 25 }) 26})