test: add domain and application layer unit tests#9
Merged
Conversation
Add comprehensive test coverage for: - merchant-category-mapping: load, hot-reload, find, add, persist - accounting.service: all methods including error paths - nlp.service: all NLP methods with mocked OpenAI - automation.service: scheduled check, partial failures, notifications All 4 modules now at 100% statement coverage. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
Part of Phase 2 (Task 007) to achieve 90%+ test coverage across the repository. Current overall coverage is 46.92%.
Approach
Added unit tests for 4 modules in the domain and application layers, mocking all external dependencies (OpenAI, Gmail, Telegram, filesystem).
Changes
src/domain/models/__tests__/merchant-category-mapping.test.ts— 15 tests covering load, hot-reload, find (exact/partial/case-insensitive), add, persist, and error handlingsrc/domain/services/__tests__/accounting.service.test.ts— 14 tests covering all AccountingService methods including error pathssrc/domain/services/__tests__/nlp.service.test.ts— 14 tests covering categorizeMerchant, autoCategorizeMerchant, parseExpenseInput, parseDateRange with success/error/edge casessrc/application/services/__tests__/automation.service.test.ts— 5 tests covering scheduledCheck with empty emails, successful processing, partial failures, and Gmail errorsTesting
npm test)Code Review