Spaces:
Sleeping
Sleeping
File size: 1,422 Bytes
d4437b5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | import assert from 'node:assert/strict';
import test from 'node:test';
import {
buildStatusBarConstraints,
constraintLabel,
withConstraintLabels,
} from '../../static/constraints.js';
// Score analysis names each constraint by its module id; the browser shows a
// readable label and colors status-bar dots by the constraint's score level.
test('constraintLabel turns analysis constraint ids into readable labels', () => {
assert.equal(constraintLabel('late_lesson'), 'Avoid Late Lessons');
assert.equal(constraintLabel('room_kind'), 'Room Kind');
assert.equal(constraintLabel('home_hub_match'), 'Home Hub Match');
});
test('buildStatusBarConstraints labels generated ids with their score level', () => {
assert.deepEqual(buildStatusBarConstraints(['assign_room', 'room_capacity', 'repeated_subject_day']), [
{ name: 'Assign Room', type: 'medium' },
{ name: 'Room Capacity', type: 'hard' },
{ name: 'Avoid Repeated Subject Day', type: 'soft' },
]);
});
test('withConstraintLabels relabels the dots repainted from analysis', () => {
const painted = [];
const statusBar = withConstraintLabels({ colorDotsFromAnalysis: (constraints) => painted.push(constraints) });
statusBar.colorDotsFromAnalysis([{ name: 'no_room_conflict', type: 'hard', score: '0hard/0medium/0soft' }]);
assert.deepEqual(painted, [[{ name: 'No Room Conflict', type: 'hard', score: '0hard/0medium/0soft' }]]);
});
|