deepkit-framework
deepkit-framework copied to clipboard
[Bug] Routes with Return Type `Promise<Response>` Not Serialized Correctly
#321 didn't manage to fix this bug completely.
This is the failing version of the current unit test
test('explicitly annotated response objects', async () => {
class Controller {
@http.GET('/a')
a(): JSONResponse {
return new JSONResponse('a');
}
@http.GET('/b')
b(): HtmlResponse {
return new HtmlResponse('b');
}
@http.GET('/c')
c(): Response {
return new Response('c', 'text/plain');
}
@http.GET('/d')
async d(): Promise<Response> {
return new Response('d', 'text/plain');
}
}
const httpKernel = createHttpKernel([Controller]);
expect((await httpKernel.request(HttpRequest.GET('/a'))).bodyString).toBe('"a"');
expect((await httpKernel.request(HttpRequest.GET('/b'))).bodyString).toBe('b');
expect((await httpKernel.request(HttpRequest.GET('/c'))).bodyString).toBe('c');
expect((await httpKernel.request(HttpRequest.GET('/d'))).bodyString).toBe('d'); // <-- this fails
});