import { describe, expect, it } from "vitest" import { layoutLanes, type LaneEvent } from "./schedule-lanes" function lanes(events: readonly LaneEvent[]) { return Object.fromEntries([...layoutLanes(events)].map(([id, lane]) => [id, lane])) } describe("layoutLanes", () => { it("ставит непересекающиеся записи в одну дорожку, каждую своим кластером", () => { expect( lanes([ { id: 1, start: "09:00", end: "10:00" }, { id: 2, start: "10:00", end: "11:00" }, ]), ).toEqual({ 1: { lane: 0, lanes: 1 }, 2: { lane: 0, lanes: 1 }, }) }) it("кладёт пересечение рядом и возвращает освободившуюся дорожку следующей записи", () => { expect( lanes([ { id: "a", start: "09:00", end: "10:00" }, { id: "b", start: "09:30", end: "11:00" }, { id: "c", start: "10:00", end: "10:30" }, ]), ).toEqual({ a: { lane: 0, lanes: 2 }, b: { lane: 1, lanes: 2 }, c: { lane: 0, lanes: 2 }, }) }) })