mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-27 22:35:23 +08:00
New definition for promisify-supertest
This commit is contained in:
18
promisify-supertest/promisify-supertest-test.ts
Normal file
18
promisify-supertest/promisify-supertest-test.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
/// <reference path="promisify-supertest.d.ts" />
|
||||
/// <reference path="../express/express.d.ts" />
|
||||
|
||||
import * as request from 'promisify-supertest';
|
||||
import * as express from 'express';
|
||||
|
||||
let app = express();
|
||||
|
||||
request(app)
|
||||
.get('/')
|
||||
.expect(200)
|
||||
.end()
|
||||
.then(function(res) {
|
||||
// blah blah blah
|
||||
})
|
||||
.catch(function(err) {
|
||||
throw err;
|
||||
});
|
||||
45
promisify-supertest/promisify-supertest.d.ts
vendored
Normal file
45
promisify-supertest/promisify-supertest.d.ts
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
// Type definitions for promisify-supertest v1.0.0
|
||||
// Project: https://www.npmjs.com/package/promisify-supertest
|
||||
// Definitions by: Leo Liang <https://github.com/aleung/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path='../superagent/superagent.d.ts' />
|
||||
/// <reference path="../express/express.d.ts" />
|
||||
|
||||
declare module 'promisify-supertest' {
|
||||
// Mostly copy-pasted from supertest.d.ts
|
||||
|
||||
import * as superagent from 'superagent';
|
||||
import * as express from 'express';
|
||||
|
||||
type CallbackHandler = (err: any, res: supertest.Response) => void;
|
||||
|
||||
function supertest(app: express.Express): supertest.SuperTest;
|
||||
|
||||
module supertest {
|
||||
function agent(app?: any): supertest.SuperTest;
|
||||
|
||||
interface SuperTest extends superagent.SuperAgent<Test> {
|
||||
}
|
||||
|
||||
interface Test extends superagent.Request<Test> {
|
||||
url: string;
|
||||
serverAddress(app: any, path: string): string;
|
||||
expect(status: number, callback?: CallbackHandler): Test;
|
||||
expect(status: number, body: string, callback?: CallbackHandler): Test;
|
||||
expect(body: string, callback?: CallbackHandler): Test;
|
||||
expect(body: RegExp, callback?: CallbackHandler): Test;
|
||||
expect(body: Object, callback?: CallbackHandler): Test;
|
||||
expect(field: string, val: string, callback?: CallbackHandler): Test;
|
||||
expect(field: string, val: RegExp, callback?: CallbackHandler): Test;
|
||||
expect(checker: (res: Response) => any): Test;
|
||||
end(callback: CallbackHandler): Test;
|
||||
end(): Promise<Response>;
|
||||
}
|
||||
|
||||
interface Response extends superagent.Response {
|
||||
}
|
||||
}
|
||||
|
||||
export = supertest;
|
||||
}
|
||||
Reference in New Issue
Block a user