test(categories): add co-located unit tests for CategoriesService - #1372
Merged
yusuftomilola merged 1 commit intoAug 26, 2026
Merged
Conversation
Covers findAll, findById, create, update, delete, not-found paths, self-parent rejection, and depreciation-defaults edge cases including zero and 100% rates. Replaces the single misplaced assertion in femaleotaku.spec.ts with focused, co-located coverage. Closes DistinctCodes#1284
|
@Magrexy Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
@Magrexy is attempting to deploy a commit to the naijabuz's projects Team on Vercel. A member of the Team first needs to authorize it. |
yusuftomilola
approved these changes
Aug 26, 2026
yusuftomilola
left a comment
Collaborator
There was a problem hiding this comment.
No merge conflicts with main. Good co-located unit test coverage for CategoriesService - approving.
3 tasks
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.
Summary
Closes #1284
Closes #1285
Closes #1286
Closes #1287
Adds a co-located
categories.service.spec.tswith 20 unit tests covering every public method inCategoriesService, replacing the single misplaced assertion infemaleotaku.spec.tswith focused, discoverable coverage.Why
The only test touching
CategoriesServicewas oneit()inbackend/src/femaleotaku.spec.ts— a file that bundles unrelated modules into a singledescribe. That test covers only the create path with depreciation defaults. Not-found paths forfindById, update, and delete had zero coverage. The self-parent rejection inupdate()was also untested. Moving tests to a co-located spec file follows the project convention and makes failures attributable to the exact module.What was built
backend/src/categories/categories.service.spec.ts:findAllfindByIdNotFoundExceptionfor missing idcreateparentCategoryId; all optional fieldsupdateNotFoundExceptionfor missing id;BadRequestExceptionfor self-parent; preserves depreciation defaults through update cycle; allows changingparentCategoryIddeleteNotFoundExceptionfor missing iddepreciation defaultsNo existing files modified — only additions, so regression risk is low.
Acceptance criteria coverage
categories.service.spec.ts— 20 tests across 6 describe groups)Test plan
npm testinbackend/— 20/20 passing (all new tests for this feature)Env vars / Notes
No new environment variables. Tests use lightweight Jest mocks for the TypeORM repository — no database connection required.