import { describe, expect, it } from 'vitest' import { MIN_DURATION_MIN, SNAP_MIN, snap, snapClamp } from '@/lib/timetable/snap' describe('snap', () => { it('rounds to nearest multiple of step', () => { expect(snap(0, 5)).toBe(0) expect(snap(2, 5)).toBe(0) expect(snap(3, 5)).toBe(5) expect(snap(7, 5)).toBe(5) expect(snap(8, 5)).toBe(10) expect(snap(12, 5)).toBe(10) expect(snap(13, 5)).toBe(15) }) it('returns value unchanged when step <= 0', () => { expect(snap(7.3, 0)).toBe(7.3) expect(snap(7.3, -1)).toBe(7.3) }) it('handles exact-multiple inputs', () => { expect(snap(15, 5)).toBe(15) expect(snap(60, 15)).toBe(60) }) it('exposes the SNAP_MIN constant', () => { expect(SNAP_MIN).toBeGreaterThan(0) expect(SNAP_MIN).toBeLessThanOrEqual(15) }) it('exposes MIN_DURATION_MIN', () => { expect(MIN_DURATION_MIN).toBe(15) }) }) describe('snapClamp', () => { it('snaps then clamps inside [min, max]', () => { expect(snapClamp(7, 5, 0, 100)).toBe(5) expect(snapClamp(-5, 5, 0, 100)).toBe(0) expect(snapClamp(150, 5, 0, 100)).toBe(100) }) })