fix architecture and write new tests
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
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',
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user