import { calculateBankedHours } from './src/lib/time-rules.js';

const tests = [
    { desc: "Standard OT (1h)", duration: 1, type: "overtime", day: "workday", expect: 1.5 },
    { desc: "Long OT (8.5h)", duration: 8.5, type: "overtime", day: "workday", expect: (7.5 * 1.5) + (1.0 * 2.0) }, // 13.25
    { desc: "Sunday OT (2h)", duration: 2, type: "overtime", day: "rest_day_2", expect: 4.0 },
    { desc: "Standby (8h)", duration: 8, type: "standby", day: "workday", expect: 1.0 },
    { desc: "Call-back short (1h)", duration: 1, type: "callback", day: "workday", expect: 4.5 },
    { desc: "Call-back Sunday (1h)", duration: 1, type: "callback", day: "rest_day_2", expect: 6.0 },

    // Non-Contiguous Hours Tests
    { desc: "Non-Contiguous (1h @ 1.5x)", duration: 1, type: "non_contiguous", day: "workday", expect: 2.0 }, // Worked=1.5, Min=2.0 -> 2.0
    { desc: "Non-Contiguous (2h @ 1.5x)", duration: 2, type: "non_contiguous", day: "workday", expect: 3.0 }, // Worked=3.0, Min=2.0 -> 3.0
];

tests.forEach(t => {
    const res = calculateBankedHours(t.duration, t.type, t.day);
    if (Math.abs(res - t.expect) < 0.01) {
        console.log(`PASS: ${t.desc} -> ${res}`);
    } else {
        console.error(`FAIL: ${t.desc} -> Expected ${t.expect}, got ${res}`);
    }
});
