Files
knowledge-governance/web/src/QAWeekPicker.test.tsx
T
姚章浩 93aabc8a81
build / build (push) Successful in 1m3s
feat(qa-ops): 重做四页布局与周报草稿导出
2026-10-18 20:00:38 +08:00

27 lines
1.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { renderToStaticMarkup } from 'react-dom/server'
import { describe, expect, it, vi } from 'vitest'
import { QAWeekPicker } from './QAWeekPicker'
describe('QA week picker', () => {
it('offers a one-click current-week shortcut', () => {
const html = renderToStaticMarkup(<QAWeekPicker year={2026} week={40} onChange={vi.fn()} />)
expect(html).toContain('>本周</button>')
})
it('shows a year and numbered weeks with visible inclusive date ranges', () => {
const html = renderToStaticMarkup(<QAWeekPicker year={2026} week={40} onChange={vi.fn()} />)
expect(html).toContain('aria-label="年份"')
expect(html).toContain('2026年')
expect(html).toContain('aria-label="周次"')
expect(html).toContain('value="40" selected=""')
expect(html).toContain('第40周(09-28 到 10-04)')
expect(html).toContain('第53周(2026-12-28 到 2027-01-03)')
expect(html).not.toContain('北京时间 · 周一至周日 · 本周截至当前')
})
it('preserves custom range mode and does not offer invalid week 53', () => {
const html = renderToStaticMarkup(<QAWeekPicker year={2027} week={null} onChange={vi.fn()} />)
expect(html).toContain('value="" selected=""')
expect(html).toContain('自定义时间')
expect(html).not.toContain('第53周')
})
})