fix architecture and write new tests
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { parseBody, parseQuery } from '../../http/validate'
|
||||
import { marketplaceReservationSchema, paginationSchema } from '../../modules/marketplace/marketplace.schemas'
|
||||
import { paySchema } from '../../modules/site/site.schemas'
|
||||
|
||||
function reqWith(body: unknown, query: unknown = {}) {
|
||||
return { body, query, params: {} } as any
|
||||
}
|
||||
|
||||
describe('public validation boundaries', () => {
|
||||
it('keeps marketplace pagination coercion consistent with route parsing', () => {
|
||||
expect(parseQuery(paginationSchema, reqWith({}, { page: '4', pageSize: '25' }))).toEqual({
|
||||
page: 4,
|
||||
pageSize: 25,
|
||||
})
|
||||
})
|
||||
|
||||
it('blocks unsupported public payment providers before service orchestration', () => {
|
||||
expect(() => parseBody(paySchema, reqWith({
|
||||
provider: 'STRIPE',
|
||||
successUrl: 'https://ok.example.test',
|
||||
failureUrl: 'https://fail.example.test',
|
||||
}))).toThrow('Validation failed')
|
||||
})
|
||||
|
||||
it('requires enough anonymous marketplace reservation identity to create a booking request', () => {
|
||||
const parsed = parseBody(marketplaceReservationSchema, reqWith({
|
||||
vehicleId: 'ckvvehicle000000000000001',
|
||||
companySlug: 'atlas-cars',
|
||||
firstName: 'Aya',
|
||||
lastName: 'Benali',
|
||||
email: 'aya@example.com',
|
||||
startDate: '2026-07-01T10:00:00.000Z',
|
||||
endDate: '2026-07-03T10:00:00.000Z',
|
||||
}))
|
||||
|
||||
expect(parsed.language).toBe('fr')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user