Skip to content

Commit 80a8c70

Browse files
v1rtlclaude
andcommitted
test(res): add test for HEAD request redirect
Add test covering the HEAD method branch in redirect.ts which sends an empty body for HEAD requests. Improves redirect.ts coverage: - Statements: 94% -> 100% - Branches: 75% -> 100% Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 34c5dcc commit 80a8c70

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

tests/modules/res.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,21 @@ describe('Response extensions', () => {
138138
}
139139
}).expect(302, '')
140140
})
141+
it('should send empty body for HEAD requests', async () => {
142+
const app = runServer((req, res) => {
143+
redirect(req, res, () => {})('/abc')
144+
})
145+
146+
const response = await makeFetch(app)('/', {
147+
method: 'HEAD',
148+
redirect: 'manual'
149+
})
150+
151+
expect(response.status).toBe(302)
152+
expect(response.headers.get('location')).toBe('/abc')
153+
const body = await response.text()
154+
expect(body).toBe('')
155+
})
141156
})
142157
describe('res.format(obj)', () => {
143158
it('should send text by default', async () => {

0 commit comments

Comments
 (0)