diff --git a/src/lib/crypto.test.ts b/src/lib/crypto.test.ts index 19b72c3..c90a973 100644 --- a/src/lib/crypto.test.ts +++ b/src/lib/crypto.test.ts @@ -16,4 +16,15 @@ describe('hashEmail', () => { const hash = hashEmail('test@example.com') 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')) + }) }) diff --git a/src/lib/result.test.ts b/src/lib/result.test.ts index 49d785b..89de3ab 100644 --- a/src/lib/result.test.ts +++ b/src/lib/result.test.ts @@ -13,4 +13,16 @@ describe('Result', () => { expect(r.ok).toBe(false) 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') + }) }) diff --git a/src/lib/validation.ts b/src/lib/validation.ts index 1bc76c1..38ace51 100644 --- a/src/lib/validation.ts +++ b/src/lib/validation.ts @@ -19,3 +19,8 @@ export const RecipientSchema = z.union([ z.object({ listId: z.string().uuid(), segmentId: z.null().optional() }), z.object({ segmentId: z.string().uuid(), listId: z.null().optional() }), ]) + +export type CreateCampaignInput = z.infer +export type UpdateCampaignInput = z.infer +export type ScheduleCampaignInput = z.infer +export type RecipientInput = z.infer