- Slide the "Ready in about" value when it changes (new EtaMessage) - Drop the "Running late" banner; delays only move the ETA now - Remove the cancel-info tooltip and its icon button - Shorten the steps toggle to "Steps" / "Hide" - Add icons and more padding to the order card action buttons Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
67 lines
1.9 KiB
TypeScript
67 lines
1.9 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { formatDuration, formatEtaClock, formatEtaParts } from '#/lib/format.ts'
|
|
|
|
describe('formatDuration', () => {
|
|
it('rounds up to at least 1 minute', () => {
|
|
expect(formatDuration(0)).toBe('1 min')
|
|
expect(formatDuration(10)).toBe('1 min')
|
|
})
|
|
|
|
it('formats minutes under an hour', () => {
|
|
expect(formatDuration(90)).toBe('2 min')
|
|
expect(formatDuration(59 * 60)).toBe('59 min')
|
|
})
|
|
|
|
it('formats whole hours without minutes', () => {
|
|
expect(formatDuration(60 * 60)).toBe('1 hr')
|
|
expect(formatDuration(3 * 60 * 60)).toBe('3 hr')
|
|
})
|
|
|
|
it('formats hours with remaining minutes', () => {
|
|
expect(formatDuration(230 * 60)).toBe('3 hr 50 min')
|
|
})
|
|
})
|
|
|
|
describe('formatEtaClock', () => {
|
|
const noon = new Date(2026, 0, 15, 12, 0, 0)
|
|
|
|
it('labels a time later the same day as today', () => {
|
|
expect(formatEtaClock(30 * 60, noon)).toBe('today, 12:30 PM')
|
|
})
|
|
|
|
it('labels a time past midnight as tomorrow', () => {
|
|
expect(formatEtaClock(13 * 60 * 60, noon)).toBe('tomorrow, 01:00 AM')
|
|
})
|
|
|
|
it('labels a time two or more days out by weekday', () => {
|
|
expect(formatEtaClock(2 * 24 * 60 * 60, noon)).toBe('Saturday, 12:00 PM')
|
|
})
|
|
})
|
|
|
|
describe('formatEtaParts', () => {
|
|
const noon = new Date(2026, 0, 15, 12, 0, 0)
|
|
|
|
it('shows the relative time at or under the 3 hour threshold', () => {
|
|
expect(formatEtaParts(34 * 60, noon)).toEqual({
|
|
prefix: 'Ready in about',
|
|
value: '34 min',
|
|
})
|
|
expect(formatEtaParts(3 * 60 * 60, noon)).toEqual({
|
|
prefix: 'Ready in about',
|
|
value: '3 hr',
|
|
})
|
|
})
|
|
|
|
it('shows the absolute time once the eta passes 3 hours', () => {
|
|
expect(formatEtaParts(3 * 60 * 60 + 60, noon)).toEqual({
|
|
prefix: 'Ready',
|
|
value: 'today, 03:01 PM',
|
|
})
|
|
expect(formatEtaParts(230 * 60, noon)).toEqual({
|
|
prefix: 'Ready',
|
|
value: 'today, 03:50 PM',
|
|
})
|
|
})
|
|
})
|