Skip to content

Unit Tests for Grants#149

Merged
prooflesben merged 9 commits intomainfrom
aaron/unit-test-for-grants
Sep 30, 2025
Merged

Unit Tests for Grants#149
prooflesben merged 9 commits intomainfrom
aaron/unit-test-for-grants

Conversation

@aaronashby
Copy link
Contributor

ℹ️ Issue

Closes #134

📝 Description

I added unit tests for each method in the grant service, mocking the parameters supplied to the DynamoDB calls, as well as the responses returned by the database.

✔️ Verification

Tests in grant.service.spec.ts
Screenshot 2025-09-20 at 3 21 37 PM

🏕️ (Optional) Future Work / Notes

It might help with descriptiveness to throw specific types of errors in the grant service instead of always throwing a general Error object. I ended up changing one of the errors in getGrantById() to a NotFoundException.

@aaronashby aaronashby linked an issue Sep 20, 2025 that may be closed by this pull request
@lyannne lyannne requested review from aditya161216 and adityapat24 and removed request for aditya161216 September 23, 2025 22:41
Copy link
Collaborator

@prooflesben prooflesben left a comment

Choose a reason for hiding this comment

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

Line 305 and line 311 make a date.now variable and compare those. It worked on your computer but on mine it was like 1 second off and errored

@aaronashby
Copy link
Contributor Author

Just added the variable in. It's a little inconsistent on my end though (sometimes I'd run the test and I'd get the same error, but other times it worked)

Copy link
Collaborator

@prooflesben prooflesben left a comment

Choose a reason for hiding this comment

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

Looks good

Copy link
Contributor

@adityapat24 adityapat24 left a comment

Choose a reason for hiding this comment

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

Looks good!

@prooflesben prooflesben merged commit 4b89c2b into main Sep 30, 2025
1 check passed
janekamata added a commit that referenced this pull request Oct 3, 2025
commit 4b89c2b
Merge: 0af71c8 e242f09
Author: prooflesben <122566738+prooflesben@users.noreply.github.com>
Date:   Tue Sep 30 18:20:36 2025 -0400

    Merge pull request #149 from Code-4-Community/aaron/unit-test-for-grants

    Unit Tests for Grants

commit 0af71c8
Merge: 0df60a3 8791fae
Author: prooflesben <122566738+prooflesben@users.noreply.github.com>
Date:   Sun Sep 28 14:59:37 2025 -0400

    Merge pull request #150 from Code-4-Community/143-dev---fix-visual-bug-aspect-ratio

    Fixed aspect ratio issue - want further testing on other devices

commit e242f09
Author: Aaron Ashby <101434393+aaronashby@users.noreply.github.com>
Date:   Sat Sep 27 23:00:31 2025 -0400

    Fixed Date.now() off-by-one test failure for addGrant()

commit 0df60a3
Merge: ba0157c bfe769d
Author: prooflesben <122566738+prooflesben@users.noreply.github.com>
Date:   Sat Sep 27 17:34:10 2025 -0400

    Merge pull request #158 from Code-4-Community/ben-pr-template

    Ben pr template

commit bfe769d
Author: prooflesben <prooflesben@gmail.com>
Date:   Sat Sep 27 17:30:19 2025 -0400

    updated template a little

commit 034a886
Author: prooflesben <prooflesben@gmail.com>
Date:   Sat Sep 27 17:28:49 2025 -0400

    Pull request template

commit 8791fae
Author: Jane Kamata <janekamata8@gmail.com>
Date:   Tue Sep 23 18:23:46 2025 -0400

    Fix footer to bottom

commit e6a77d2
Author: Jane Kamata <janekamata8@gmail.com>
Date:   Tue Sep 23 16:45:32 2025 -0400

    Fix for "margins" on side

commit 560237f
Author: Jane Kamata <janekamata8@gmail.com>
Date:   Mon Sep 22 17:08:52 2025 -0400

    Fixed aspect ratio issue - want further testing on other devices

commit 82c6666
Author: Aaron Ashby <101434393+aaronashby@users.noreply.github.com>
Date:   Sat Sep 20 15:36:45 2025 -0400

    Set environment variable for grant table name in test environment

commit 53e5312
Author: Aaron Ashby <101434393+aaronashby@users.noreply.github.com>
Date:   Fri Sep 19 20:07:44 2025 -0400

    Added "toHaveBeenCalledWith"'s to tests

commit ad572a8
Author: Aaron Ashby <101434393+aaronashby@users.noreply.github.com>
Date:   Fri Sep 19 20:01:06 2025 -0400

    Added tests for addGrant()

commit 3e1054b
Author: Aaron Ashby <101434393+aaronashby@users.noreply.github.com>
Date:   Fri Sep 19 19:25:52 2025 -0400

    Added invalid test case for updateGrant()

commit 539a912
Author: Aaron Ashby <101434393+aaronashby@users.noreply.github.com>
Date:   Fri Sep 19 19:14:07 2025 -0400

    Added tests for updateGrant()

commit 8cf2c56
Author: Aaron Ashby <101434393+aaronashby@users.noreply.github.com>
Date:   Wed Sep 17 12:00:49 2025 -0400

    Added tests for unarchiveGrants()

commit bdfe2cd
Author: Aaron Ashby <101434393+aaronashby@users.noreply.github.com>
Date:   Wed Sep 17 10:55:31 2025 -0400

    Added tests for getGrantById()

commit 06ba437
Author: Aaron Ashby <101434393+aaronashby@users.noreply.github.com>
Date:   Tue Sep 16 23:50:15 2025 -0400

    Added tests for getAllGrants()
@prooflesben prooflesben deleted the aaron/unit-test-for-grants branch October 4, 2025 18:46
janekamata added a commit that referenced this pull request Oct 4, 2025
commit 4b89c2b
Merge: 0af71c8 e242f09
Author: prooflesben <122566738+prooflesben@users.noreply.github.com>
Date:   Tue Sep 30 18:20:36 2025 -0400

    Merge pull request #149 from Code-4-Community/aaron/unit-test-for-grants

    Unit Tests for Grants

commit 0af71c8
Merge: 0df60a3 8791fae
Author: prooflesben <122566738+prooflesben@users.noreply.github.com>
Date:   Sun Sep 28 14:59:37 2025 -0400

    Merge pull request #150 from Code-4-Community/143-dev---fix-visual-bug-aspect-ratio

    Fixed aspect ratio issue - want further testing on other devices

commit e242f09
Author: Aaron Ashby <101434393+aaronashby@users.noreply.github.com>
Date:   Sat Sep 27 23:00:31 2025 -0400

    Fixed Date.now() off-by-one test failure for addGrant()

commit 0df60a3
Merge: ba0157c bfe769d
Author: prooflesben <122566738+prooflesben@users.noreply.github.com>
Date:   Sat Sep 27 17:34:10 2025 -0400

    Merge pull request #158 from Code-4-Community/ben-pr-template

    Ben pr template

commit bfe769d
Author: prooflesben <prooflesben@gmail.com>
Date:   Sat Sep 27 17:30:19 2025 -0400

    updated template a little

commit 034a886
Author: prooflesben <prooflesben@gmail.com>
Date:   Sat Sep 27 17:28:49 2025 -0400

    Pull request template

commit 8791fae
Author: Jane Kamata <janekamata8@gmail.com>
Date:   Tue Sep 23 18:23:46 2025 -0400

    Fix footer to bottom

commit e6a77d2
Author: Jane Kamata <janekamata8@gmail.com>
Date:   Tue Sep 23 16:45:32 2025 -0400

    Fix for "margins" on side

commit 560237f
Author: Jane Kamata <janekamata8@gmail.com>
Date:   Mon Sep 22 17:08:52 2025 -0400

    Fixed aspect ratio issue - want further testing on other devices

commit 82c6666
Author: Aaron Ashby <101434393+aaronashby@users.noreply.github.com>
Date:   Sat Sep 20 15:36:45 2025 -0400

    Set environment variable for grant table name in test environment

commit 53e5312
Author: Aaron Ashby <101434393+aaronashby@users.noreply.github.com>
Date:   Fri Sep 19 20:07:44 2025 -0400

    Added "toHaveBeenCalledWith"'s to tests

commit ad572a8
Author: Aaron Ashby <101434393+aaronashby@users.noreply.github.com>
Date:   Fri Sep 19 20:01:06 2025 -0400

    Added tests for addGrant()

commit 3e1054b
Author: Aaron Ashby <101434393+aaronashby@users.noreply.github.com>
Date:   Fri Sep 19 19:25:52 2025 -0400

    Added invalid test case for updateGrant()

commit 539a912
Author: Aaron Ashby <101434393+aaronashby@users.noreply.github.com>
Date:   Fri Sep 19 19:14:07 2025 -0400

    Added tests for updateGrant()

commit 8cf2c56
Author: Aaron Ashby <101434393+aaronashby@users.noreply.github.com>
Date:   Wed Sep 17 12:00:49 2025 -0400

    Added tests for unarchiveGrants()

commit bdfe2cd
Author: Aaron Ashby <101434393+aaronashby@users.noreply.github.com>
Date:   Wed Sep 17 10:55:31 2025 -0400

    Added tests for getGrantById()

commit 06ba437
Author: Aaron Ashby <101434393+aaronashby@users.noreply.github.com>
Date:   Tue Sep 16 23:50:15 2025 -0400

    Added tests for getAllGrants()
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.

DEV - Create unit test for grants

3 participants