import { describe, expect, it } from 'vitest' import { historyQuerySchema, idParamSchema, preferencesSchema, unreadQuerySchema } from './notification.schemas' describe('notification schema contracts', () => { it('requires complete preference entries', () => { expect(preferencesSchema.parse([{ notificationType: 'NEW_BOOKING', channel: 'EMAIL', enabled: true }])).toEqual([ { notificationType: 'NEW_BOOKING', channel: 'EMAIL', enabled: true }, ]) expect(() => preferencesSchema.parse([{ notificationType: 'NEW_BOOKING', channel: 'EMAIL' }])).toThrow() expect(() => preferencesSchema.parse([{ notificationType: 'RESERVATION_CREATED', channel: 'EMAIL', enabled: true }])).toThrow() expect(() => preferencesSchema.parse([{ notificationType: 'NEW_BOOKING', channel: 'PUSH', enabled: true }])).toThrow() }) it('coerces history limits and caps bulk history requests', () => { expect(historyQuerySchema.parse({ channel: 'EMAIL', status: 'SENT', limit: '25' })).toEqual({ channel: 'EMAIL', status: 'SENT', limit: 25, }) expect(() => historyQuerySchema.parse({ limit: '0' })).toThrow() expect(() => historyQuerySchema.parse({ limit: '501' })).toThrow() }) it('accepts unread query passthrough but rejects empty ids', () => { expect(unreadQuerySchema.parse({ unread: 'true' })).toEqual({ unread: 'true' }) expect(idParamSchema.parse({ id: 'notification_1' })).toEqual({ id: 'notification_1' }) expect(() => idParamSchema.parse({ id: '' })).toThrow() }) })