Skip to content

Commit 6dc537c

Browse files
committed
test: add test for not returning res object
1 parent a0f9580 commit 6dc537c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/e2e.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import express from 'express';
44
import type { NextApiRequest, NextApiResponse } from 'next';
55
import request from 'supertest';
66
import { createHandler } from './createHandler';
7-
import { Body, Delete, Get, Header, HttpCode, Post, Put, Query, Req, Response, SetHeader } from './decorators';
7+
import { Body, Delete, Get, Header, HttpCode, Post, Put, Query, Req, Res, Response, SetHeader } from './decorators';
88
import { ParseBooleanPipe } from './pipes/parseBoolean.pipe';
99
import { ParseNumberPipe } from './pipes/parseNumber.pipe';
1010

@@ -62,8 +62,12 @@ class TestHandler {
6262

6363
@Put()
6464
@SetHeader('X-Method', 'update')
65-
public update(@Header('Content-Type') contentType: string, @Query('id') id: string, @Body() body: any) {
66-
return { contentType, id, receivedBody: body, test: this.testField };
65+
public update(@Req() req: NextApiRequest, @Res() res: NextApiResponse) {
66+
const { headers, query, body } = req;
67+
const { 'content-type': contentType } = headers;
68+
const { id } = query;
69+
70+
res.status(200).json({ contentType, id, receivedBody: body, test: this.testField });
6771
}
6872

6973
@Delete()

0 commit comments

Comments
 (0)