Skip to content

test(domain): add reimbursements logic unit tests#5

Open
LogenNineFingersIsAlive wants to merge 2 commits intomainfrom
feat/reimbursements-unit-tests
Open

test(domain): add reimbursements logic unit tests#5
LogenNineFingersIsAlive wants to merge 2 commits intomainfrom
feat/reimbursements-unit-tests

Conversation

@LogenNineFingersIsAlive
Copy link
Collaborator

Summary

Phase 2 (part 1) of domain testability: extract and unit-test reimbursements business logic.

What changed

  • Added new pure logic module:
    • packages/domain/src/services/reimbursements-logic.ts
  • Added unit tests:
    • packages/domain/src/services/__tests__/reimbursements-logic.test.ts
  • Refactored reimbursements.service.ts to consume extracted pure helpers (no behavior changes intended)

Covered logic

  • Positive minor validation
  • Recoverable amount computation
  • Reimbursement status derivation (none, expected, partial, settled, written_off)
  • Outbound reimbursable assertions
  • Inbound target/currency/amount link validations
  • Close/write-off amount validations
  • Category rule kind validations
  • Auto-match helpers:
    • recovery window inclusion
    • allocation amount calculation

Validation

  • pnpm --filter @tithe/domain typecheck
  • pnpm --filter @tithe/domain test:coverage
  • pnpm lint

Results:

  • 131 domain unit tests passing (expenses + reimbursements logic suites)
  • reimbursements-logic.ts at 100% statement/branch/function/line coverage

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves domain-layer testability by extracting reimbursement business rules from reimbursements.service.ts into a pure logic module and adding a dedicated unit test suite, while keeping service behavior unchanged.

Changes:

  • Added reimbursements-logic.ts containing pure validation/derivation helpers used by the reimbursements service.
  • Refactored reimbursements.service.ts to delegate to the extracted helpers.
  • Added reimbursements-logic.test.ts unit tests covering reimbursement logic paths.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
packages/domain/src/services/reimbursements.service.ts Refactors service to call extracted pure helpers (validation, status derivation, auto-match helpers).
packages/domain/src/services/reimbursements-logic.ts New pure business-logic module for reimbursements, intended for unit testing.
packages/domain/src/services/tests/reimbursements-logic.test.ts New Vitest suite covering the extracted reimbursement logic helpers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants