24 lines
792 B
TypeScript
24 lines
792 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { reportQuerySchema, summaryQuerySchema } from './analytics.schemas'
|
|
|
|
describe('analytics schema contracts', () => {
|
|
it('defaults summary period to the 30 day window', () => {
|
|
expect(summaryQuerySchema.parse({})).toEqual({ period: '30d' })
|
|
})
|
|
|
|
it('defaults reports to JSON while preserving explicit date range filters', () => {
|
|
expect(reportQuerySchema.parse({ from: '2026-01-01', to: '2026-01-31' })).toEqual({
|
|
from: '2026-01-01',
|
|
to: '2026-01-31',
|
|
format: 'JSON',
|
|
})
|
|
})
|
|
|
|
it('passes CSV format and period through without lowercasing surprises', () => {
|
|
expect(reportQuerySchema.parse({ format: 'CSV', period: 'quarter' })).toEqual({
|
|
format: 'CSV',
|
|
period: 'quarter',
|
|
})
|
|
})
|
|
})
|