import { describe, expect, it } from 'vitest'; import { formatShanghaiDateTime, formatShanghaiTime } from './datetime'; describe('A 股时间显示格式化', () => { it('将 UTC ISO 时间转换为上海时区的完整日期时间', () => { expect(formatShanghaiDateTime('2026-08-24T14:16:26.813Z')).toBe('2026-08-24 22:16:26'); }); it('将 UTC ISO 时间转换为上海时区的时分秒', () => { expect(formatShanghaiTime('2026-08-24T14:16:26.813Z')).toBe('22:16:26'); }); it('收到空值或非法日期时返回占位符', () => { expect(formatShanghaiDateTime(undefined)).toBe('—'); expect(formatShanghaiTime('not-a-date')).toBe('—'); }); });