23 lines
853 B
TypeScript
23 lines
853 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { endOfWeek, formatDate, monthGrid, startOfWeek, timeFromMinutes, minutesOfDay } from '@/utils/date'
|
|
|
|
describe('date utils', () => {
|
|
it('uses Monday as the first day of a week', () => {
|
|
expect(formatDate(startOfWeek('2026-06-28'))).toBe('2026-06-22')
|
|
expect(formatDate(endOfWeek('2026-06-28'))).toBe('2026-06-28')
|
|
})
|
|
|
|
it('builds a 42-cell month grid with surrounding days', () => {
|
|
const grid = monthGrid('2026-06-15')
|
|
|
|
expect(grid).toHaveLength(42)
|
|
expect(grid[0]).toEqual({ date: '2026-06-01', day: 1, isCurrentMonth: true })
|
|
expect(grid[41]).toEqual({ date: '2026-07-12', day: 12, isCurrentMonth: false })
|
|
})
|
|
|
|
it('converts time and minutes symmetrically', () => {
|
|
expect(minutesOfDay('13:45')).toBe(825)
|
|
expect(timeFromMinutes(825)).toBe('13:45')
|
|
})
|
|
})
|