test: add missing tests for companyClosures, lowPriorityDays, and manual flag
This commit is contained in:
@@ -99,4 +99,26 @@ function emp(id, constraints = {}) {
|
|||||||
assert.equal(result[0].employeeId, 'bob', 'bob (0 history) beats alice (5 history)');
|
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.');
|
console.log('All algorithm tests passed.');
|
||||||
|
|||||||
Reference in New Issue
Block a user