Skip to content
Source
Sign inSign up
TanStack/schemas
Open History to see the last commit

release-dates.test.ts

73 lines2.6 KB

1import { describe, expect, it } from 'vitest'
2​
3import {
4 ELEVENLABS_RELEASE_DATES,
5 GEMINI_RELEASE_DATES,
6 byteplusIdSuffixDate,
7 curatedReleasedAt,
8 dateToEpoch,
9 geminiIdSuffixDate,
10 isoToEpochSeconds,
11} from './release-dates.ts'
12​
13describe('release date helpers', () => {
14 it('converts YYYY-MM-DD to UTC-midnight epoch seconds', () => {
15 expect(dateToEpoch('2025-11-20')).toBe(1_763_596_800)
16 expect(dateToEpoch('2015-01-01')).toBe(1_420_070_400)
17 })
18​
19 it('parses ISO timestamps and rejects garbage', () => {
20 expect(isoToEpochSeconds('2025-11-20T14:27:03.344Z')).toBe(1_763_648_823)
21 expect(isoToEpochSeconds('2026-06-29T00:00:00Z')).toBe(1_782_691_200)
22 expect(isoToEpochSeconds('not-a-date')).toBeNull()
23 expect(isoToEpochSeconds(undefined)).toBeNull()
24 expect(isoToEpochSeconds(null)).toBeNull()
25 })
26​
27 it('extracts the MM-YYYY month embedded in Gemini preview ids', () => {
28 expect(geminiIdSuffixDate('gemini-2.5-computer-use-preview-10-2025')).toBe(
29 dateToEpoch('2025-10-01'),
30 )
31 expect(geminiIdSuffixDate('antigravity-preview-05-2026')).toBe(
32 dateToEpoch('2026-05-01'),
33 )
34 // Version-suffixed ids must not parse as dates.
35 expect(geminiIdSuffixDate('gemini-2.0-flash-001')).toBeNull()
36 expect(geminiIdSuffixDate('gemini-2.5-pro')).toBeNull()
37 // Month out of range.
38 expect(geminiIdSuffixDate('model-preview-13-2025')).toBeNull()
39 })
40​
41 it('extracts the YYMMDD suffix embedded in dated BytePlus ids', () => {
42 expect(byteplusIdSuffixDate('seedance-1-5-pro-251215')).toBe(
43 dateToEpoch('2025-12-15'),
44 )
45 expect(byteplusIdSuffixDate('dola-seed-2-1-turbo-260628')).toBe(
46 dateToEpoch('2026-06-28'),
47 )
48 // Undated Seed Speech ids and short numeric suffixes must not parse.
49 expect(byteplusIdSuffixDate('seed-audio-1.0')).toBeNull()
50 expect(byteplusIdSuffixDate('seed-asr')).toBeNull()
51 expect(byteplusIdSuffixDate('gpt-4-0613')).toBeNull()
52 // Implausible month/day.
53 expect(byteplusIdSuffixDate('model-251345')).toBeNull()
54 expect(byteplusIdSuffixDate('model-250099')).toBeNull()
55 })
56​
57 it('resolves curated dates and misses to null', () => {
58 expect(curatedReleasedAt({ 'my-model': '2024-07-01' }, 'my-model')).toBe(
59 dateToEpoch('2024-07-01'),
60 )
61 expect(curatedReleasedAt({}, 'unknown-model')).toBeNull()
62 })
63​
64 it('keeps curated maps parseable', () => {
65 for (const [rawId, date] of [
66 ...Object.entries(GEMINI_RELEASE_DATES),
67 ...Object.entries(ELEVENLABS_RELEASE_DATES),
68 ]) {
69 expect(date, rawId).toMatch(/^\d{4}-\d{2}-\d{2}$/)
70 expect(Number.isNaN(dateToEpoch(date)), rawId).toBe(false)
71 }
72 })
73})