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

import { ShiftTimer } from './ShiftTimer.js';

test('ShiftTimer computes elapsed and remaining seconds from shift start', () => {
  const now = new Date('2026-04-25T12:00:00Z').getTime();
  const timer = new ShiftTimer({
    durationSeconds: 2400,
    tickSeconds: 30,
    save: {
      get() {
        return { shift_started_at: '2026-04-25T11:30:00Z' };
      }
    },
    now: () => now
  });

  const snapshot = timer.getSnapshot();
  assert.equal(snapshot.elapsedSeconds, 1800);
  assert.equal(snapshot.remainingSeconds, 600);
  assert.equal(snapshot.durationSeconds, 2400);
});
