import { describe, expect, it } from 'vitest' import { floor, reach } from './reach' /** * The ladder's two invariants, which are what make it a ladder rather than a * list of numbers. Neither is visible in a review: a rung written out of order * still compiles and still renders, and a rung lowered under the floor renders * a target a thumb misses. */ describe('the height ladder', () => { it('ascends, so a rung is always taller than the one under it', () => { const rungs = Object.values(reach) expect(rungs).toStrictEqual([...rungs].sort((a, b) => a - b)) expect(new Set(rungs).size).toBe(rungs.length) }) it('clears the target floor at every rung but the one that is not a target', () => { const { mark, ...targets } = reach expect(mark).toBeLessThan(floor) for (const [name, height] of Object.entries(targets)) { expect(`${name} ${height >= floor}`).toBe(`${name} true`) } }) })