31 lines
1.4 KiB
TypeScript
31 lines
1.4 KiB
TypeScript
// apps/app/tests/unit/utils/statusSeverity.consistency.spec.ts
|
|
import { describe, expect, it } from 'vitest'
|
|
import { ShiftAssignmentStatus } from '@/types/shiftAssignment'
|
|
import { PersonStatus } from '@/types/person'
|
|
import { MatchStatus } from '@/types/identityMatch'
|
|
import { ArtistEngagementStatus, PaymentStatus } from '@/types/timetable'
|
|
import { STATUS_SEVERITY, statusSeverity } from '@/components-v2/shared/statusSeverity'
|
|
|
|
const ENUMS = { ShiftAssignmentStatus, ArtistEngagementStatus, PaymentStatus, PersonStatus, MatchStatus }
|
|
const ALL_VALUES = Object.values(ENUMS).flatMap(e => Object.values(e)) as string[]
|
|
|
|
describe('statusSeverity §8.X enforcement', () => {
|
|
it('completeness: every live enum value resolves to an explicit severity (no dev-fallback)', () => {
|
|
const missing = ALL_VALUES.filter(v => !(v in STATUS_SEVERITY))
|
|
|
|
expect(missing, `unmapped enum values: ${missing.join(', ')}`).toEqual([])
|
|
})
|
|
|
|
it('no phantoms: every map key exists in at least one live enum', () => {
|
|
const orphans = Object.keys(STATUS_SEVERITY).filter(k => !ALL_VALUES.includes(k))
|
|
|
|
expect(orphans, `orphan keys: ${orphans.join(', ')}`).toEqual([])
|
|
})
|
|
|
|
it('resolver returns the mapped severity and never throws on a known value', () => {
|
|
expect(statusSeverity('approved')).toBe('success')
|
|
expect(statusSeverity('no_show')).toBe('danger')
|
|
expect(statusSeverity('deposit_paid')).toBe('info')
|
|
})
|
|
})
|