Also excludes node_modules.nosync from vitest test discovery to fix pre-existing bleed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FFDuBhMKvoWjrWT3ZnGmmr
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { buildJkkp6Pdf, buildJkkp7Pdf } from '@/lib/pdf/jkkp'
|
|
|
|
const mockIncident = {
|
|
reference_no: 'TEST-202607-0001',
|
|
incident_type: 'injury',
|
|
description: 'Worker fell from platform',
|
|
reported_at: new Date('2026-07-01T08:00:00Z').toISOString(),
|
|
severity: 4,
|
|
is_fatality: false,
|
|
is_serious_bodily_injury: true,
|
|
is_dangerous_occurrence: false,
|
|
lost_days: 5,
|
|
site_name: 'Setia Corporation Warehouse 1',
|
|
reporter_name: 'John Doe',
|
|
}
|
|
|
|
describe('buildJkkp6Pdf', () => {
|
|
it('returns a non-empty Uint8Array', async () => {
|
|
const pdf = await buildJkkp6Pdf(mockIncident)
|
|
expect(pdf).toBeInstanceOf(Uint8Array)
|
|
expect(pdf.length).toBeGreaterThan(100)
|
|
})
|
|
|
|
it('PDF bytes start with %PDF', async () => {
|
|
const pdf = await buildJkkp6Pdf(mockIncident)
|
|
const header = new TextDecoder().decode(pdf.slice(0, 4))
|
|
expect(header).toBe('%PDF')
|
|
})
|
|
})
|
|
|
|
describe('buildJkkp7Pdf', () => {
|
|
it('returns a non-empty Uint8Array', async () => {
|
|
const pdf = await buildJkkp7Pdf(mockIncident)
|
|
expect(pdf).toBeInstanceOf(Uint8Array)
|
|
expect(pdf.length).toBeGreaterThan(100)
|
|
})
|
|
|
|
it('PDF bytes start with %PDF', async () => {
|
|
const pdf = await buildJkkp7Pdf(mockIncident)
|
|
const header = new TextDecoder().decode(pdf.slice(0, 4))
|
|
expect(header).toBe('%PDF')
|
|
})
|
|
})
|