import { describe, expect, it } from 'vitest' import { findNearestTimeSlotIndex, formatTimeSlot, fromMinutes, generateTimeSlots, toMinutes, useTimeUtils, } from '../../composables/useTimeUtils' describe('useTimeUtils', () => { it('formats HH:MM slots for shared picker display', () => { expect(formatTimeSlot('00:00')).toBe('00:00') expect(formatTimeSlot('14:30', '12h')).toBe('2:30 PM') }) it('converts between HH:MM strings and minute offsets', () => { expect(toMinutes('09:45')).toBe(585) expect(fromMinutes(585)).toBe('09:45') }) it('finds the nearest slot index for scroll and highlight behavior', () => { const slots = generateTimeSlots('09:00', '10:00', 15) expect(findNearestTimeSlotIndex('09:37', slots)).toBe(2) expect(findNearestTimeSlotIndex('08:00', [])).toBe(-1) }) it('exposes the shared slot helpers from the composable facade', () => { const utils = useTimeUtils() expect(utils.formatTimeSlot('23:15', '12h')).toBe('11:15 PM') expect(utils.findNearestTimeSlotIndex('10:20', ['10:00', '10:30'])).toBe(1) }) })