import { describe, it, expect } from 'vitest' import { DOW, DOW_EN, bydayFromDate } from '../src/lib/weekday.js' describe('weekday', () => { it('DOW 有 7 项, 首项为周日', () => { expect(DOW).toHaveLength(7) expect(DOW[0]).toBe('周日') expect(DOW[6]).toBe('周六') }) it('DOW_EN 按 JS getDay 索引 (0=周日)', () => { expect(DOW_EN).toEqual(['SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA']) }) it('bydayFromDate 返回 Date 对应的 BYDAY 编码', () => { // 2026-07-27 是周一 -> getDay()=1 -> 'MO' expect(bydayFromDate(new Date(2026, 6, 27))).toBe('MO') // 2026-08-01 是周六 -> getDay()=6 -> 'SA' expect(bydayFromDate(new Date(2026, 7, 1))).toBe('SA') }) })