Two files, two scopes. Don’t conflate them.
Files
| File | Lines | Subject |
|---|---|---|
src/lib/validation.test.ts | 180 | Generic input validators in src/lib/validation.ts |
src/validationEngine.test.ts | 32 | The four-layer enrichment validation in src/validationEngine.ts |
src/lib/validation.test.ts
Pure unit tests for HTTP-input validation primitives:
isValidUUID/UUID_REGEX: accepts canonical and uppercase UUIDs; rejects too-short, invalid chars, emptyisValidEmail/EMAIL_REGEX: accepts plus-tag and multi-dot TLDs; rejects bare@example.com,user@, emptyisValidOrgNr: rejects too-short and non-numeric- Note:
'556000-0000'is rejected (expect(isValidOrgNr('556000-0000')).toBe(false)) because it fails the Luhn check — the test comment acknowledges that “actual valid Swedish org numbers would pass” but does not provide one
- Note:
validatePassword: requires length ≥ 8, lowercase, uppercase, digit, and rejects common patterns (Password123flagged as common)sanitizeString: trims, removes null bytes, caps at 10000 charsvalidateSearchQuery: rejects single chars and empty/null; truncates to 100 charsvalidatePagination: defaultslimit=20,offset=0; caps at the third argument (default 100); accepts string inputs; clamps negative values tolimit≥1,offset≥0isValidURL: accepts http/https; rejectsftp://, plain text, empty
src/validationEngine.test.ts
Two thin tests against validateCompany() from src/validationEngine.ts:
- Returns an object with boolean
isHeltValideradand a definedconfidenceScore isHeltValiderad === (confidenceScore >= 0.7)
Warning
This file is a smoke test, not a real test of validation behaviour. It does not exercise individual validation layers (
src/validation/layers/registryLayer.ts,newsLayer.ts), does not assert specific score values, and depends on the mock layers (src/mocks/) producing semi-deterministic output. Compare with the depth of Lead Scoring — which is largely untested at the engine level.
Gaps
src/validation/layers/registryLayer.tsandnewsLayer.tshave no direct testssrc/api/validation.ts(the request-shape validators distinct fromsrc/lib/validation.ts) is partially exercised throughtests/api/structure.test.tsand the API CRUD tests, but has no dedicated unit suite
See also
Test Strategy, Lead Scoring, Test Coverage Gaps.