From adf656c9f31b1352b644c37f9524e6762791cc37 Mon Sep 17 00:00:00 2001 From: Ferdinand Date: Wed, 8 Apr 2026 13:16:46 +0200 Subject: [PATCH] test: add missing tests for companyClosures, lowPriorityDays, and manual flag --- tests/algorithm.test.mjs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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.');