test: add unit tests for Context model helpers and problem middleware#2072
Open
chengyixu wants to merge 1 commit intoasyncapi:masterfrom
Open
test: add unit tests for Context model helpers and problem middleware#2072chengyixu wants to merge 1 commit intoasyncapi:masterfrom
chengyixu wants to merge 1 commit intoasyncapi:masterfrom
Conversation
Addresses issues asyncapi#2016 and asyncapi#2019: - test/unit/domains/models/Context.test.ts: covers uncovered branches of isContextFileEmpty() including empty store, non-empty store, current set, and two-key edge case; also validates IContextFile interface shapes. - test/unit/apps/api/middlewares/problem.middleware.test.ts: covers all branches of problemMiddleware: 4xx response, 5xx response with no stack/cause, status defaulting to 500 when falsy, non-ProblemException falling into catch block calling next(), and type prefix stripping. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
|
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.



What?
Adds unit tests targeting the low-coverage areas identified in issues #2016 and #2019.
New test files
test/unit/domains/models/Context.test.ts(closes #2016)Covers the uncovered branches of
isContextFileEmpty()— the pure helper that is called inside every mutating Context function:currentfield →truefalsecurrentset with populated store →falsecurrentset with empty store (two keys so length check fails) →falseAlso validates the
IContextFileinterface shapes for documentation clarity.test/unit/apps/api/middlewares/problem.middleware.test.ts(closes #2019)Covers all uncovered branches of
problemMiddleware:500error.get()throws (non-ProblemException) → catch block callsnext(err)Why?
Both
Context.tsandproblem.middleware.tshad very low branch coverage masked by aggregate totals. These tests directly target the branches listed in the issue descriptions.How to test