test: add unit tests for compileQueryParser, compileTrust, and normalizeTypes#7038
Open
tommyhgunz14 wants to merge 1 commit intoexpressjs:masterfrom
Open
test: add unit tests for compileQueryParser, compileTrust, and normalizeTypes#7038tommyhgunz14 wants to merge 1 commit intoexpressjs:masterfrom
tommyhgunz14 wants to merge 1 commit intoexpressjs:masterfrom
Conversation
…izeTypes Add comprehensive test coverage for three previously untested utility functions in lib/utils.js: - compileQueryParser: tests for true, false, 'simple', 'extended', custom function, and invalid string values - compileTrust: tests for true, custom function, numeric hop count, comma-separated strings, and undefined/falsy values - normalizeTypes: tests for shorthand types, full MIME types, empty arrays, and quality parameters These tests follow the same patterns used in the existing compileETag test suite.
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
Adds comprehensive test coverage for three previously untested utility functions in
lib/utils.js.Problem
The following utility functions in
lib/utils.jshad no dedicated unit tests:compileQueryParser()— compiles the query parser setting into a functioncompileTrust()— compiles the proxy trust setting into a functionnormalizeTypes()— normalizes an array of type strings to MIME type objectsWhile
compileETag()recently received test coverage (PR #6534), these three sibling functions remained untested.Changes
Added 17 new test cases to
test/utils.js:compileQueryParser()(8 tests)trueand'simple''extended'and parses nested query stringsundefinedforfalseTypeErrorfor unknown string valuescompileTrust()(5 tests)truefortrueundefined/falsy valuesnormalizeTypes()(4 tests)'html'→'text/html')Testing
All 37 tests pass (21ms):
Test style follows the existing patterns used in
compileETagandnormalizeTypetest suites.