mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-13 21:06:14 +08:00
Merge pull request #19526 from fabiob/master
chai-http: added Request.parse() method and friends
This commit is contained in:
@@ -41,6 +41,16 @@ chai.request(app)
|
||||
.get('/search')
|
||||
.query({ name: 'foo', limit: 10 });
|
||||
|
||||
chai.request(app)
|
||||
.get('/download')
|
||||
.buffer()
|
||||
.parse((res, cb) => {
|
||||
let data = '';
|
||||
res.setEncoding('binary');
|
||||
res.on('data', (chunk: any) => { data += chunk; });
|
||||
res.on('end', () => { cb(undefined, new Buffer(data, 'binary')); });
|
||||
});
|
||||
|
||||
chai.request(app)
|
||||
.put('/user/me')
|
||||
.send({ passsword: '123', confirmPassword: '123' })
|
||||
|
||||
3
types/chai-http/index.d.ts
vendored
3
types/chai-http/index.d.ts
vendored
@@ -49,6 +49,8 @@ declare global {
|
||||
type: string;
|
||||
status: number;
|
||||
text: string;
|
||||
setEncoding(encoding: string): void;
|
||||
on(event: string, fn: (...args: any[]) => void): void;
|
||||
}
|
||||
|
||||
interface Request extends FinishedRequest {
|
||||
@@ -59,6 +61,7 @@ declare global {
|
||||
auth(user: string, name: string): Request;
|
||||
field(name: string, val: string): Request;
|
||||
buffer(): Request;
|
||||
parse(fn: (res: Response, cb: (e?: Error, r?: any) => void) => void): Request;
|
||||
end(callback?: (err: any, res: Response) => void): FinishedRequest;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user