mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 23:41:08 +02:00
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>
15 lines
390 B
JavaScript
15 lines
390 B
JavaScript
module.exports = {
|
|
moduleFileExtensions: ['js', 'json', 'ts'],
|
|
rootDir: 'src',
|
|
testRegex: '.*\\.spec\\.ts$',
|
|
transform: {
|
|
'^.+\\.(t|j)s$': 'ts-jest',
|
|
},
|
|
collectCoverageFrom: ['**/*.(t|j)s', '!**/index.ts', '!**/*.interface.ts', '!**/*.d.ts'],
|
|
coverageDirectory: '../coverage',
|
|
testEnvironment: 'node',
|
|
verbose: true,
|
|
clearMocks: true,
|
|
restoreMocks: true,
|
|
resetMocks: true,
|
|
};
|