diff --git a/tests/algorithm.test.mjs b/tests/algorithm.test.mjs index 19af5fa..8e07b79 100644 --- a/tests/algorithm.test.mjs +++ b/tests/algorithm.test.mjs @@ -99,4 +99,26 @@ function emp(id, constraints = {}) { assert.equal(result[0].employeeId, 'bob', 'bob (0 history) beats alice (5 history)'); } +// companyClosures excluded from workdays +{ + const days = getWorkdays(2026, 4, [], ['2026-04-01']); + assert.equal(days.length, 21, 'Closure reduces count by 1'); + assert.ok(!days.includes('2026-04-01'), 'Closure date excluded'); +} + +// lowPriorityDays reduces score — bob without penalty wins over alice with penalty +{ + // 2026-04-01 = Wednesday (3); alice has lowPriorityDays on Wednesday + // Both have same history (0) — alice's score gets -5 penalty, bob wins + const employees = [emp('alice', {lowPriorityDays:[3]}), emp('bob')]; + const result = generatePlan(['2026-04-01'], employees, [], fixed); + assert.equal(result[0].employeeId, 'bob', 'alice low priority on Wednesday → bob wins'); +} + +// manual: false on auto-assigned entries +{ + const result = generatePlan(['2026-04-01'], [emp('alice')], [], fixed); + assert.equal(result[0].manual, false, 'auto-assignment sets manual: false'); +} + console.log('All algorithm tests passed.');