Skip to content

Commit

Permalink
chore(http): add failing test for #614
Browse files Browse the repository at this point in the history
  • Loading branch information
marcj committed Sep 27, 2024
1 parent 0b37a21 commit ab96f2f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/http/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,12 @@ Content-Type: application/json\r
return this;
}

query(query: any): this {
this.queryPath = querystring.stringify(query);
query(query: any | string): this {
if ('string' === typeof query) {
this.queryPath = query;
} else {
this.queryPath = querystring.stringify(query);
}
return this;
}
}
Expand Down
19 changes: 19 additions & 0 deletions packages/http/tests/router.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1727,6 +1727,25 @@ test('required fields in body should be required', async () => {
expect((await httpKernel.request(HttpRequest.POST('/').json({ a: 'a', b: 'asd' }))).json).toEqual(['a', 'asd']);
});

test('query validator withing HttpQuery', async () => {
class Controller {
@http.GET('do')
async do(
a: HttpQuery<string & MinLength<8>>,
b: HttpQuery<string>,
) {
return { valid: true };
}
}

const httpKernel = createHttpKernel([Controller]);

//todo: fix this, see https://github.com/deepkit/deepkit-framework/issues/614
// expect((await httpKernel.request(HttpRequest.GET('/do').query('a=aaaaaaaa&b=bbbb'))).json).toMatchObject({
// valid: true
// });
});

test('http body deep optional union', async () => {
interface AdTitleAndBasicAttributes {
title: string;
Expand Down

0 comments on commit ab96f2f

Please sign in to comment.