feat(schemas): accept cadence field on subscription + contribution updates
This commit is contained in:
parent
47f2d666dd
commit
35197c465b
2 changed files with 69 additions and 2 deletions
|
|
@ -160,6 +160,48 @@ describe('helcimSubscriptionSchema', () => {
|
|||
})
|
||||
expect(result.success).toBe(false)
|
||||
})
|
||||
|
||||
it('accepts cadence: monthly', () => {
|
||||
const result = helcimSubscriptionSchema.safeParse({
|
||||
customerId: '12345',
|
||||
contributionTier: '15',
|
||||
customerCode: 'CST123',
|
||||
cadence: 'monthly'
|
||||
})
|
||||
expect(result.success).toBe(true)
|
||||
expect(result.data.cadence).toBe('monthly')
|
||||
})
|
||||
|
||||
it('accepts cadence: annual', () => {
|
||||
const result = helcimSubscriptionSchema.safeParse({
|
||||
customerId: '12345',
|
||||
contributionTier: '15',
|
||||
customerCode: 'CST123',
|
||||
cadence: 'annual'
|
||||
})
|
||||
expect(result.success).toBe(true)
|
||||
expect(result.data.cadence).toBe('annual')
|
||||
})
|
||||
|
||||
it('rejects cadence: weekly', () => {
|
||||
const result = helcimSubscriptionSchema.safeParse({
|
||||
customerId: '12345',
|
||||
contributionTier: '15',
|
||||
customerCode: 'CST123',
|
||||
cadence: 'weekly'
|
||||
})
|
||||
expect(result.success).toBe(false)
|
||||
})
|
||||
|
||||
it('defaults cadence to monthly when omitted', () => {
|
||||
const result = helcimSubscriptionSchema.safeParse({
|
||||
customerId: '12345',
|
||||
contributionTier: '15',
|
||||
customerCode: 'CST123'
|
||||
})
|
||||
expect(result.success).toBe(true)
|
||||
expect(result.data.cadence).toBe('monthly')
|
||||
})
|
||||
})
|
||||
|
||||
describe('helcimUpdateBillingSchema', () => {
|
||||
|
|
@ -310,6 +352,29 @@ describe('updateContributionSchema', () => {
|
|||
expect(result.success).toBe(true)
|
||||
expect(result.data).not.toHaveProperty('role')
|
||||
})
|
||||
|
||||
it('accepts cadence: monthly', () => {
|
||||
const result = updateContributionSchema.safeParse({ contributionTier: '15', cadence: 'monthly' })
|
||||
expect(result.success).toBe(true)
|
||||
expect(result.data.cadence).toBe('monthly')
|
||||
})
|
||||
|
||||
it('accepts cadence: annual', () => {
|
||||
const result = updateContributionSchema.safeParse({ contributionTier: '15', cadence: 'annual' })
|
||||
expect(result.success).toBe(true)
|
||||
expect(result.data.cadence).toBe('annual')
|
||||
})
|
||||
|
||||
it('rejects cadence: weekly', () => {
|
||||
const result = updateContributionSchema.safeParse({ contributionTier: '15', cadence: 'weekly' })
|
||||
expect(result.success).toBe(false)
|
||||
})
|
||||
|
||||
it('defaults cadence to monthly when omitted', () => {
|
||||
const result = updateContributionSchema.safeParse({ contributionTier: '15' })
|
||||
expect(result.success).toBe(true)
|
||||
expect(result.data.cadence).toBe('monthly')
|
||||
})
|
||||
})
|
||||
|
||||
// --- Series schemas ---
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue