import test from 'node:test';import assert from 'node:assert/strict'; import {mapCourierState,mapContextRows} from '../src/fleetContext.mjs'; const c={id:1,online:true,occupied:false,postalCode:'10115'}; test('rejection is pink while occupied, offline and invalid postal positions retain precedence',()=>{ assert.equal(mapCourierState(c,true).color,'#be185d');assert.equal(mapCourierState(c,false).color,'#15803d'); assert.equal(mapCourierState({...c,occupied:true},true).color,'#be123c'); assert.equal(mapCourierState(c,true,{occupied:true}).color,'#be123c'); assert.equal(mapCourierState({...c,online:false},true).color,'#64748b'); assert.equal(mapCourierState({...c,postalCode:'n/a'},true).color,'#b45309'); }); test('map intersects current positions with eligible stable identities in ranking order',()=>{ const rows=[c,{...c,id:2},{...c,id:3}],context={assignedCourier:3,items:[{courierId:2,rank:1,blockers:[]},{courierId:3,rank:2,blockers:['Gesperrt']},{courierId:1,rank:4,blockers:[]},{courierId:99,rank:5,blockers:[]}]}; assert.deepEqual(mapContextRows(rows,context,'CANDIDATES').map(c=>c.id),[2,1]); assert.deepEqual(mapContextRows(rows,context,'ASSIGNED').map(c=>c.id),[3]); assert.deepEqual(mapContextRows(rows,null,'CANDIDATES'),[]);assert.equal(mapContextRows(rows,null,'ALL'),rows); assert.deepEqual(rows.map(c=>c.id),[1,2,3]); });