feat(validation): rename contributionTier → contributionAmount in Zod schemas
This commit is contained in:
parent
55af652263
commit
e4dade18b9
3 changed files with 49 additions and 35 deletions
|
|
@ -42,7 +42,7 @@ describe('memberCreateSchema', () => {
|
|||
email: 'new@example.com',
|
||||
name: 'Test User',
|
||||
circle: 'community',
|
||||
contributionTier: '0'
|
||||
contributionAmount: 0
|
||||
}
|
||||
|
||||
it('accepts valid member data', () => {
|
||||
|
|
@ -80,9 +80,16 @@ describe('memberCreateSchema', () => {
|
|||
expect(result.success).toBe(false)
|
||||
})
|
||||
|
||||
it('rejects invalid contributionTier enum', () => {
|
||||
const result = memberCreateSchema.safeParse({ ...validMember, contributionTier: '999' })
|
||||
expect(result.success).toBe(false)
|
||||
it('accepts contributionAmount: 0, 7, 9999', () => {
|
||||
expect(memberCreateSchema.safeParse({ ...validMember, contributionAmount: 0 }).success).toBe(true)
|
||||
expect(memberCreateSchema.safeParse({ ...validMember, contributionAmount: 7 }).success).toBe(true)
|
||||
expect(memberCreateSchema.safeParse({ ...validMember, contributionAmount: 9999 }).success).toBe(true)
|
||||
})
|
||||
|
||||
it('rejects invalid contributionAmount values', () => {
|
||||
expect(memberCreateSchema.safeParse({ ...validMember, contributionAmount: -1 }).success).toBe(false)
|
||||
expect(memberCreateSchema.safeParse({ ...validMember, contributionAmount: 1.5 }).success).toBe(false)
|
||||
expect(memberCreateSchema.safeParse({ ...validMember, contributionAmount: '15' }).success).toBe(false)
|
||||
})
|
||||
|
||||
it('rejects missing required fields', () => {
|
||||
|
|
@ -246,7 +253,7 @@ describe('validateBody', () => {
|
|||
it('strips unknown fields from output', async () => {
|
||||
const event = createMockEvent({
|
||||
method: 'POST',
|
||||
body: { email: 'test@example.com', name: 'Test', circle: 'community', contributionTier: '0', role: 'admin', _id: 'fake' }
|
||||
body: { email: 'test@example.com', name: 'Test', circle: 'community', contributionAmount: 0, role: 'admin', _id: 'fake' }
|
||||
})
|
||||
const data = await validateBody(event, memberCreateSchema)
|
||||
expect(data).not.toHaveProperty('role')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue