import { describe, expect, it } from 'vitest'; import { inputTextRoom, ROW_GAP, valueSpan } from '../../src/editor/graph/portRow'; describe('the input text of a port row', () => { it('keeps its own limit while the output label leaves room for it', () => { expect(inputTextRoom(15, 108, 140)).toBe(108); }); it('gives way before the output label, keeping the gap', () => { expect(inputTextRoom(15, 108, 100)).toBe(100 - ROW_GAP - 15); }); it('keeps its full limit on a row without an output', () => { expect(inputTextRoom(15, 108, null)).toBe(108); }); it('gets no room at all rather than a negative one', () => { expect(inputTextRoom(15, 108, 10)).toBe(0); }); }); describe('the value a run shows beside an output', () => { it('sits between the input text and the output label', () => { expect(valueSpan(60, 120)).toEqual({ left: 60 + ROW_GAP, right: 120 - ROW_GAP }); }); it('never starts right of where it has to end', () => { const span = valueSpan(110, 116); expect(span.left).toBeLessThanOrEqual(span.right); }); });