Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
fullstack ruleP1universalStack: typescript
testingcoverageedge-casescorrectness
Test functions with inputs that represent their real accepted types
Exercise a function with the kinds of inputs it actually accepts (e.g. a Date for a Moment-input parser), not just the type that happens to be returned, so the test proves real behavior.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | expect(datetime.rawDate('2024-01-10T11:02:35+01:00')).toBe('2024-01-10T11:02:35+01:00'); |
| 2 | // only proves it echoes a string back |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | expect(datetime.rawDate(new Date('2024-01-10T11:02:35+01:00'))).toBe('2024-01-10T11:02:35+01:00'); |
| 2 | // proves it actually formats a Date input |
Explanation (EN)
Objašnjenje (HR)