Wuesteon
|
c5d662bb89
|
✅ test(cors): add comprehensive unit tests for shared-nestjs-cors
Add 63 unit tests with 100% code coverage for CORS configuration utilities.
**Test Coverage:**
- createCorsConfig() function (24 tests)
- Default behavior and configuration structure
- Environment variable parsing (comma-separated, trimming)
- includeAllManaApps flag functionality
- Custom development origins
- Additional origins (mobile apps)
- Origin deduplication across all sources
- Combined options integration
- createCorsConfigWithCallback() function (15 tests)
- Callback mode for mobile app support
- No origin handling (server-to-server)
- Valid/invalid origin validation
- Security: protocol-sensitive matching
- Callback return value validation
- Origin constants (24 tests)
- MANACORE_STAGING_ORIGINS validation
- MANACORE_PRODUCTION_ORIGINS validation
- MANACORE_ALL_APP_ORIGINS combination
- URL format validation
- Duplicate detection
- Consistency between environments
**Results:**
- 63 tests passing
- 100% code coverage (statements, branches, functions, lines)
- All edge cases covered (empty values, whitespace, duplicates)
**Setup:**
- Added Jest with ts-jest for TypeScript support
- Added test scripts: test, test:watch, test:coverage
- Created jest.config.js with coverage configuration
- Proper TypeScript types for callback functions
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-12-17 18:11:13 +01:00 |
|