import { describe, it } from 'node:test' import assert from 'node:assert/strict' import { calcLeaveHours, DEFAULT_LEAVE_WORK_HOURS } from './oa-leave-hours' describe('calcLeaveHours', () => { const wh = DEFAULT_LEAVE_WORK_HOURS it('same day morning+afternoon sample 09:00-15:00 => 5.0', () => { assert.equal(calcLeaveHours('2026-07-30 09:00', '2026-07-30 15:00', wh), 5.0) }) it('only morning', () => { assert.equal(calcLeaveHours('2026-07-30 08:30', '2026-07-30 12:00', wh), 3.5) }) it('gap across lunch not counted', () => { assert.equal(calcLeaveHours('2026-07-30 11:00', '2026-07-30 14:00', wh), 2.0) }) it('end before start => null', () => { assert.equal(calcLeaveHours('2026-07-30 15:00', '2026-07-30 09:00', wh), null) }) it('invalid => null', () => { assert.equal(calcLeaveHours('', '2026-07-30 09:00', wh), null) }) })