test(core): add unit tests for normalizeHeaders and createFetchWithInit#1374
test(core): add unit tests for normalizeHeaders and createFetchWithInit#1374k61b wants to merge 9 commits intomodelcontextprotocol:mainfrom
Conversation
|
@modelcontextprotocol/client
@modelcontextprotocol/server
@modelcontextprotocol/express
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive unit tests for two utility functions (normalizeHeaders and createFetchWithInit) in the transport module that previously lacked dedicated test coverage. The tests verify various input formats for header normalization and proper merging behavior for fetch initialization options.
Key changes:
- New test file with 142 lines covering two utility functions
- Tests for
normalizeHeadersvalidate handling of undefined, Headers instances, arrays of tuples, and plain objects - Tests for
createFetchWithInitverify base initialization passthrough, option merging, and header merging precedence
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
76779f6 to
3f7ef90
Compare
Add unit tests for
normalizeHeadersandcreateFetchWithInitinpackages/core/src/shared/transport.ts.Motivation and Context
These utility functions are used by both
SSEClientTransportandStreamableHTTPClientTransportbut had no dedicated unit tests. Adding coverage helps catch regressions and documents expected behavior.How Has This Been Tested?
Breaking Changes
None. Test-only change.
Types of changes
(This is a test-only change)
Checklist
Additional context
Tests cover:
normalizeHeaders: undefined, Headers instance, array of tuples, plain objectscreateFetchWithInit: base init passthrough, option merging, header merging precedence