Add PR checks workflow and Vitest coverage (#97)
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { deriveCheckStatus } from './client'
|
||||
|
||||
describe('deriveCheckStatus', () => {
|
||||
it('returns neutral when no checks are present', () => {
|
||||
expect(deriveCheckStatus(null)).toBe('neutral')
|
||||
expect(deriveCheckStatus([])).toBe('neutral')
|
||||
})
|
||||
|
||||
it('returns failure when a failed check is present', () => {
|
||||
expect(
|
||||
deriveCheckStatus([
|
||||
{ status: 'QUEUED' },
|
||||
{ conclusion: 'FAILURE' }
|
||||
])
|
||||
).toBe('failure')
|
||||
})
|
||||
|
||||
it('returns pending when checks are still running', () => {
|
||||
expect(deriveCheckStatus([{ status: 'IN_PROGRESS' }])).toBe('pending')
|
||||
})
|
||||
|
||||
it('returns success when all checks complete without failures', () => {
|
||||
expect(
|
||||
deriveCheckStatus([
|
||||
{ conclusion: 'SUCCESS' },
|
||||
{ conclusion: 'SKIPPED' }
|
||||
])
|
||||
).toBe('success')
|
||||
})
|
||||
})
|
||||
@@ -127,7 +127,7 @@ export async function listIssues(repoPath: string, limit = 20): Promise<IssueInf
|
||||
}
|
||||
}
|
||||
|
||||
function mapPRState(state: string): PRInfo['state'] {
|
||||
export function mapPRState(state: string): PRInfo['state'] {
|
||||
const s = state?.toUpperCase()
|
||||
if (s === 'MERGED') {
|
||||
return 'merged'
|
||||
@@ -139,7 +139,7 @@ function mapPRState(state: string): PRInfo['state'] {
|
||||
return 'open'
|
||||
}
|
||||
|
||||
function deriveCheckStatus(rollup: unknown[] | null | undefined): CheckStatus {
|
||||
export function deriveCheckStatus(rollup: unknown[] | null | undefined): CheckStatus {
|
||||
if (!rollup || !Array.isArray(rollup) || rollup.length === 0) {
|
||||
return 'neutral'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user