Skip to content

test: Add Tests for /api/credit/lines and /api/credit/lines/:id Endpoints (#29)#71

Open
Bug-Hunter-X wants to merge 4 commits intoCreditra:mainfrom
Bug-Hunter-X:test/credit-lines-endpoints
Open

test: Add Tests for /api/credit/lines and /api/credit/lines/:id Endpoints (#29)#71
Bug-Hunter-X wants to merge 4 commits intoCreditra:mainfrom
Bug-Hunter-X:test/credit-lines-endpoints

Conversation

@Bug-Hunter-X
Copy link
Contributor

Overview

Adds focused integration tests for credit line list/detail endpoints, including empty-list behavior, success responses, and not-found responses.
Also adds minimal route error-path tests to ensure the credit route file meets the required route-level coverage threshold.

Closes #29

Changes

Credit Route Endpoint Tests

  • [ADD] src/test/creditLinesEndpoints.test.ts
    • Added tests for GET /api/credit/lines:
    • Returns 200 with empty list when store is empty.
    • Returns all lines for success/future growth cases.
    • Returns JSON content-type.
    • Added tests for GET /api/credit/lines/:id:
    • Returns 200 with full credit line payload for known ID.
    • Returns 404 with consistent not-found format for unknown ID.
    • Returns JSON content-type on not-found response.

Route Coverage Support

  • [ADD] src/test/creditRouteErrorHandling.test.ts
    • Added minimal tests for unexpected error handling in credit route POST handlers to cover 500 fallback branches.
    • Ensures route file reaches required coverage threshold without changing endpoint behavior.

Documentation

  • [MODIFY] README.md
    • Added a testing note for running credit lines endpoint tests.

Tooling / Test Dependencies

  • [MODIFY] package.json
    • Added supertest and @types/supertest under dev dependencies.
  • [MODIFY] package-lock.json
    • Lockfile updates for added test dependencies.

How to Run Tests

npm test -- src/__test__/creditLinesEndpoints.test.ts src/__test__/creditRouteErrorHandling.test.ts

# Route coverage for credit route:
npx vitest run src/__test__/creditLinesEndpoints.test.ts src/__test__/creditRouteErrorHandling.test.ts --coverage --coverage.include=src/routes/credit.ts --coverage.reporter=text

Verification Results

Requirement Status
Tests for /api/credit/lines Done
Tests for /api/credit/lines/:id Done
Empty list behavior covered Done
Not-found behavior covered Done
Success cases covered Done
Route coverage >=95% Done (100% for src/routes/credit.ts)
Documentation updated Done

Verification Evidence

  • npm test -- src/__test__/creditLinesEndpoints.test.ts src/__test__/creditRouteErrorHandling.test.ts
    • Passed: 2 test files, 14 tests.
image
  • npx vitest run src/__test__/creditLinesEndpoints.test.ts src/__test__/creditRouteErrorHandling.test.ts --coverage --coverage.include=src/routes/credit.ts --coverage.reporter=text
    • src/routes/credit.ts: 100% statements, 100% branches, 100% functions, 100% lines.
image

@Bug-Hunter-X
Copy link
Contributor Author

@greatest0fallt1me rei=view and merge sir

@greatest0fallt1me
Copy link
Contributor

@Bug-Hunter-X Can you resolve the conflicts?

@Bug-Hunter-X
Copy link
Contributor Author

@Bug-Hunter-X Can you resolve the conflicts?

DONE boss

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.

Add tests for /api/credit/lines and /api/credit/lines/:id endpoints

2 participants