import assert from 'node:assert/strict'
import test from 'node:test'

import { getWorkerSessionExpiryDelay } from '../src/utils/worker-auth.ts'

test('worker session expiry delay handles valid, expired, and invalid timestamps', () => {
  const now = Date.parse('2026-08-30T09:00:00.000Z')
  assert.equal(getWorkerSessionExpiryDelay('2026-08-30T09:00:05.000Z', now), 5_000)
  assert.equal(getWorkerSessionExpiryDelay('2026-08-30T08:59:59.000Z', now), 0)
  assert.equal(getWorkerSessionExpiryDelay('not-a-date', now), null)
  assert.equal(getWorkerSessionExpiryDelay('', now), null)
})
