Skip to content

Commit

Permalink
fix(test): param controller test add await
Browse files Browse the repository at this point in the history
  • Loading branch information
yviscool committed Jun 26, 2019
1 parent 6278d99 commit b955427
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
23 changes: 14 additions & 9 deletions packages/midway-web/test/enhance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,50 +163,55 @@ describe('/test/enhance.test.ts', () => {

app.mockCsrf();

request(app.callback())
await request(app.callback())
.get('/param/12/test?name=1')
.expect(200)
.expect({id: '12', name: '1'});

await request(app.callback())
.get('/param/query?name=1')
.expect(200)
.expect({name: '1'});

request(app.callback())
await request(app.callback())
.get('/param/query_id?id=1')
.expect(200)
.expect('1');

request(app.callback())
await request(app.callback())
.get('/param/param/12/test/456')
.expect(200)
.expect({id: '12', userId: '456'});

request(app.callback())
await request(app.callback())
.get('/param/param/12')
.expect(200)
.expect('12');

request(app.callback())
await request(app.callback())
.post('/param/body')
.type('form')
.send({ id: '1' })
.expect(200)
.expect({id: '1'});

request(app.callback())
await request(app.callback())
.get('/param/body_id')
.type('form')
.send({ id: '1' })
.expect(200)
.expect('1');

request(app.callback())
await request(app.callback())
.get('/param/session')
.expect('{}');

request(app.callback())
await request(app.callback())
.get('/param/headers')
.expect(200)
.expect('127');

request(app.callback())
await request(app.callback())
.get('/param/headers_host')
.expect(200)
.expect('127');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ export class ParamController {
ctx.body = query;
}

@get('/:id/test')
async test(@query() query, @ctx() ctx, @param('id') id) {
const data = {
id,
...query
};
ctx.body = data;
}

@get('/query_id')
async queryId(@query('id') id, @ctx() ctx) {
ctx.body = id;
Expand Down

0 comments on commit b955427

Please sign in to comment.