Add Jest coverage for donors API and model - #1
Draft
Shrichackran with Copilot wants to merge 1 commit into
Draft
Conversation
Agent-Logs-Url: https://github.com/Shrichackran/LifeLink---Smart-Blood-Donation-Platform/sessions/3115ebcd-d15c-4fc7-b309-dc86fa1f0fe8 Co-authored-by: Shrichackran <221295906+Shrichackran@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
Shrichackran
April 28, 2026 07:54
View session
There was a problem hiding this comment.
Pull request overview
Adds Jest-based test coverage for the donors API endpoint and the donor model’s query construction, enabling safer refactors of core donor-matching behavior.
Changes:
- Add Jest + Supertest dev dependencies and
npm testscript/config. - Refactor
app.jsto be importable in tests (only listen when run as main). - Add route-level tests for
/donorsvalidation/success/error paths and a unit test for model SQL + parameter binding.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| package.json | Adds Jest/Supertest and Jest config; introduces npm test. |
| package-lock.json | Locks new dev dependencies required for tests. |
| app.js | Exports Express app and guards listen() for testability. |
| tests/donorRoutes.test.js | Adds Supertest coverage for /donors request handling. |
| tests/donorModel.test.js | Adds unit test asserting SQL shape and bound params for getDonors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| expect(donorModel.getDonors).toHaveBeenCalledWith("A+", "Chennai", expect.any(Function)); | ||
| expect(response.status).toBe(500); | ||
| expect(response.body).toEqual(error); |
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.
Test coverage was missing for the donors API and its database query logic, leaving core matching behavior unverified. This adds focused tests around request validation, error handling, and query construction.
Example (route error handling):