fix: TriggerType-Typisierung, z.infer-Exporte, fehlende Tests für Result und hashEmail

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-17 08:15:13 +00:00
parent b63ce058a0
commit 689fbac795
3 changed files with 28 additions and 0 deletions

View File

@@ -16,4 +16,15 @@ describe('hashEmail', () => {
const hash = hashEmail('test@example.com') const hash = hashEmail('test@example.com')
expect(hash).not.toContain('@') expect(hash).not.toContain('@')
}) })
it('gibt den korrekten SHA256-Hash zurück (Determinismus)', () => {
// SHA256 von 'test@example.com' — extern verifiziert
const { createHash } = require('crypto')
const expected = createHash('sha256').update('test@example.com').digest('hex')
expect(hashEmail('test@example.com')).toBe(expected)
})
it('trimmt Whitespace vor dem Hashing', () => {
expect(hashEmail(' test@example.com ')).toBe(hashEmail('test@example.com'))
})
}) })

View File

@@ -13,4 +13,16 @@ describe('Result', () => {
expect(r.ok).toBe(false) expect(r.ok).toBe(false)
if (!r.ok) expect(r.error.message).toBe('fail') if (!r.ok) expect(r.error.message).toBe('fail')
}) })
it('ok(undefined) ist gültig', () => {
const r = ok(undefined)
expect(r.ok).toBe(true)
if (r.ok) expect(r.data).toBeUndefined()
})
it('err akzeptiert beliebige Error-Typen', () => {
const r = err('string-fehler')
expect(r.ok).toBe(false)
if (!r.ok) expect(r.error).toBe('string-fehler')
})
}) })

View File

@@ -19,3 +19,8 @@ export const RecipientSchema = z.union([
z.object({ listId: z.string().uuid(), segmentId: z.null().optional() }), z.object({ listId: z.string().uuid(), segmentId: z.null().optional() }),
z.object({ segmentId: z.string().uuid(), listId: z.null().optional() }), z.object({ segmentId: z.string().uuid(), listId: z.null().optional() }),
]) ])
export type CreateCampaignInput = z.infer<typeof CreateCampaignSchema>
export type UpdateCampaignInput = z.infer<typeof UpdateCampaignSchema>
export type ScheduleCampaignInput = z.infer<typeof ScheduleCampaignSchema>
export type RecipientInput = z.infer<typeof RecipientSchema>