653074be3e
Build & Push / Pipeline Tests (push) Failing after 1m26s
Build & Push / Build & Push Docker Image (push) Has been skipped
Test / Type Check (all packages) (push) Successful in 49s
Test / API Unit Tests (push) Failing after 1m8s
Test / Homepage Unit Tests (push) Successful in 44s
Test / Carplace Unit Tests (push) Successful in 42s
Test / Admin Unit Tests (push) Successful in 39s
Test / Dashboard Unit Tests (push) Successful in 45s
Test / API Integration Tests (push) Failing after 1m7s
19 lines
1.1 KiB
TypeScript
19 lines
1.1 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { manualPaymentSchema, paymentParamSchema, refundSchema, reservationParamSchema } from './payment.schemas'
|
|
|
|
describe('payment schemas edge cases', () => {
|
|
it('defaults manual payment currency/type and accepts supported methods', () => {
|
|
expect(manualPaymentSchema.parse({ amount: 500, paymentMethod: 'BANK_TRANSFER' })).toMatchObject({ amount: 500, currency: 'MAD', type: 'CHARGE' })
|
|
expect(manualPaymentSchema.safeParse({ amount: 0, paymentMethod: 'CHECK' }).success).toBe(false)
|
|
expect(manualPaymentSchema.safeParse({ amount: 100, paymentMethod: 'PAYPAL' }).success).toBe(false)
|
|
expect(manualPaymentSchema.safeParse({ amount: 100, paymentMethod: 'CASH' }).success).toBe(false)
|
|
})
|
|
|
|
it('validates refund and payment parameter payloads', () => {
|
|
expect(refundSchema.parse({})).toEqual({})
|
|
expect(refundSchema.safeParse({ amount: -1 }).success).toBe(false)
|
|
expect(reservationParamSchema.safeParse({ id: '' }).success).toBe(false)
|
|
expect(paymentParamSchema.safeParse({ reservationId: 'reservation_1', paymentId: 'payment_1' }).success).toBe(true)
|
|
})
|
|
})
|