test(response): cover blob body and header setting#128
Conversation
…context Asserts the behaviors documented for discussion #121: returning a Response with a Blob body and custom headers, setting headers with @res() while returning a value, and setting body/headers with @context(). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UnF4fzmM7CwBfq7zXBnQsF
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughThe controller adds routes that return a Blob, mutate headers through ChangesResponse decorator coverage
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
@Req and @res are built with createParamDecorator, which returns a decorator factory (() => DecoratorFunction), but they were typed as DecoratorFunction directly. This made the documented @Req()/@res() usage fail to type-check. Type them as factories, matching @Header/@context. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UnF4fzmM7CwBfq7zXBnQsF
There was a problem hiding this comment.
🧹 Nitpick comments (2)
spec/response-decorator.test.ts (2)
15-39: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUse tabs for indentation.
The added controller routes (and the new tests below) are indented with spaces. Project convention is tabs.
As per coding guidelines: "Use tabs for indentation".
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@spec/response-decorator.test.ts` around lines 15 - 39, The new controller routes in response-decorator.test.ts are using spaces instead of the project’s tab indentation. Update the affected methods in the controller snippet, including blobWithHeaders, setHeaderWithRes, and setBodyWithContext, so their indentation matches the rest of the file and uses tabs consistently.Source: Coding guidelines
64-116: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider grouping related assertions with
testContext.step(...).The three new cases each spin up, init, listen, and close their own
DanetApplication. Since they cover the same response-decorator surface, they could be consolidated into a singleDeno.testusingtestContext.step(...)to reduce app-lifecycle boilerplate and keep related assertions together.As per coding guidelines: "Use
testContext.step(...)to group related assertions in oneDeno.test".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@spec/response-decorator.test.ts` around lines 64 - 116, Group the three response-decorator assertions into a single Deno.test using testContext.step(...) instead of separate test cases. Reuse one DanetApplication lifecycle for the shared setup/teardown, and place the Blob, `@Res`, and `@Context` checks into named steps so the related assertions stay together while reducing repeated init/listen/close boilerplate.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@spec/response-decorator.test.ts`:
- Around line 15-39: The new controller routes in response-decorator.test.ts are
using spaces instead of the project’s tab indentation. Update the affected
methods in the controller snippet, including blobWithHeaders, setHeaderWithRes,
and setBodyWithContext, so their indentation matches the rest of the file and
uses tabs consistently.
- Around line 64-116: Group the three response-decorator assertions into a
single Deno.test using testContext.step(...) instead of separate test cases.
Reuse one DanetApplication lifecycle for the shared setup/teardown, and place
the Blob, `@Res`, and `@Context` checks into named steps so the related assertions
stay together while reducing repeated init/listen/close boilerplate.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: bfe0c0b7-a3d5-460c-88a7-6661c9cc15c1
📒 Files selected for processing (1)
spec/response-decorator.test.ts
Hono's c.body() Data type does not accept a raw Uint8Array under Deno 2's stricter lib types. Use a string body so the test type-checks on both Deno v1.x and v2.x. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UnF4fzmM7CwBfq7zXBnQsF
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UnF4fzmM7CwBfq7zXBnQsF
Addresses discussion #121: "How can I set the headers of the response and the body as a blob?"
Adds tests to
spec/response-decorator.test.tsasserting the three supported ways to do this:Responsewith aBlobbody + custom headers (Content-Type,Content-Disposition, custom header) — sent as-is.@Res()to mutate response headers while returning a plain value (Danet mergescontext.res.headers).@Context()to set the body and headers via Hono helpers (c.header(),c.body()).The matching user-facing documentation lives in a companion PR on
Savory/docs.🤖 Generated with Claude Code
Generated by Claude Code
Summary by CodeRabbit
Content-TypeandContent-Disposition.Req/Res) for better type safety.