mirror of
https://github.com/stablyai/orca.git
synced 2026-10-22 16:03:47 +00:00
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import type { PRInfo, PRRefreshOutcome } from './types'
|
|
import { normalizeGitHubPRForBranchOutcome } from './github-pr-for-branch-outcome'
|
|
|
|
const PR = {
|
|
number: 42,
|
|
title: 'Feature',
|
|
state: 'merged',
|
|
url: 'https://github.com/acme/orca/pull/42',
|
|
checksStatus: 'success',
|
|
updatedAt: '2026-08-04T22:46:08Z',
|
|
mergeable: 'UNKNOWN'
|
|
} as PRInfo
|
|
|
|
describe('normalizeGitHubPRForBranchOutcome', () => {
|
|
it('preserves current classified outcomes', () => {
|
|
const outcome: PRRefreshOutcome = { kind: 'found', pr: PR, fetchedAt: 10 }
|
|
expect(normalizeGitHubPRForBranchOutcome(outcome, 20)).toBe(outcome)
|
|
})
|
|
|
|
it('normalizes legacy PRInfo and null responses', () => {
|
|
expect(normalizeGitHubPRForBranchOutcome(PR, 20)).toEqual({
|
|
kind: 'found',
|
|
pr: PR,
|
|
fetchedAt: 20
|
|
})
|
|
expect(normalizeGitHubPRForBranchOutcome(null, 20)).toEqual({
|
|
kind: 'no-pr',
|
|
fetchedAt: 20
|
|
})
|
|
})
|
|
|
|
it('preserves classified upstream errors', () => {
|
|
const outcome: PRRefreshOutcome = {
|
|
kind: 'upstream-error',
|
|
errorType: 'network',
|
|
message: 'network unavailable',
|
|
fetchedAt: 10
|
|
}
|
|
expect(normalizeGitHubPRForBranchOutcome(outcome, 20)).toBe(outcome)
|
|
})
|
|
})
|