update suparagent and supertest type definitions

This commit is contained in:
Horiuchi_H
2015-02-17 16:48:40 +09:00
parent 25286fd7b2
commit e263035131
4 changed files with 379 additions and 181 deletions
+6 -6
View File
@@ -11,7 +11,7 @@ supertest(app)
.expect('Content-Type', /json/)
.expect('Content-Length', '20')
.expect(201)
.end((err, res) => {
.end((err: any, res: supertest.Response) => {
if (err) throw err;
});
@@ -20,13 +20,13 @@ var request = supertest(app);
var agent = supertest.agent();
request
.post('/login')
.end((err, res) => {
.end((err: any, res: supertest.Response) => {
if (err) throw err;
agent.saveCookies(res);
var req = request.get('/admin');
agent.attachCookies(req);
req.expect(200, (err, res) => {
req.expect(200, (err: any, res: supertest.Response) => {
if (err) throw err;
});
});
@@ -35,11 +35,11 @@ request
var client = supertest.agent(app);
client
.post('/login')
.end((err, res) => {
.end((err: any, res: supertest.Response) => {
if (err) throw err;
client.get('/admin')
.expect(200, (err, res) => {
.expect(200, (err: any, res: supertest.Response) => {
if (err) throw err;
});
});
@@ -48,7 +48,7 @@ client
supertest(app)
.get('/')
.expect(hasPreviousAndNextKeys)
.end((err, res) => {
.end((err: any, res: supertest.Response) => {
if (err) throw err;
});
+25 -86
View File
@@ -8,93 +8,32 @@
declare module "supertest" {
import superagent = require('superagent');
module supertest {
interface Test extends superagent.Request {
url: string;
serverAddress(app: any, path: string): string;
expect(status: number, callback?: (err: Error, res: Response) => void): Test;
expect(status: number, body: string, callback?: (err: Error, res: Response) => void): Test;
expect(body: string, callback?: (err: Error, res: Response) => void): Test;
expect(body: RegExp, callback?: (err: Error, res: Response) => void): Test;
expect(body: Object, callback?: (err: Error, res: Response) => void): Test;
expect(field: string, val: string, callback?: (err: Error, res: Response) => void): Test;
expect(field: string, val: RegExp, callback?: (err: Error, res: Response) => void): Test;
expect(checker: (res: Response) => any): Test;
attach(field: string, file: string, filename: string): Test;
redirects(n: number): Test;
part(): Test;
set(field: string, val: string): Test;
set(field: Object): Test;
type(val: string): Test;
query(val: Object): Test;
send(data: string): Test;
send(data: Object): Test;
buffer(val: boolean): Test;
timeout(ms: number): Test;
clearTimeout(): Test;
auth(user: string, name: string): Test;
field(name: string, val: string): Test;
end(callback?: (err: Error, res: Response) => void): Test;
}
interface Response extends superagent.Response {}
interface SuperTest {
get(url: string): Test;
post(url: string): Test;
put(url: string): Test;
head(url: string): Test;
del(url: string): Test;
options(url: string): Test;
trace(url: string): Test;
copy(url: string): Test;
lock(url: string): Test;
mkcol(url: string): Test;
move(url: string): Test;
propfind(url: string): Test;
proppatch(url: string): Test;
unlock(url: string): Test;
report(url: string): Test;
mkactivity(url: string): Test;
checkout(url: string): Test;
merge(url: string): Test;
//m-search(url: string): Test;
notify(url: string): Test;
subscribe(url: string): Test;
unsubscribe(url: string): Test;
patch(url: string): Test;
}
interface TestAgent extends superagent.Agent {
get(url: string, callback?: (err: Error, res: Response) => void): Test;
post(url: string, callback?: (err: Error, res: Response) => void): Test;
put(url: string, callback?: (err: Error, res: Response) => void): Test;
head(url: string, callback?: (err: Error, res: Response) => void): Test;
del(url: string, callback?: (err: Error, res: Response) => void): Test;
options(url: string, callback?: (err: Error, res: Response) => void): Test;
trace(url: string, callback?: (err: Error, res: Response) => void): Test;
copy(url: string, callback?: (err: Error, res: Response) => void): Test;
lock(url: string, callback?: (err: Error, res: Response) => void): Test;
mkcol(url: string, callback?: (err: Error, res: Response) => void): Test;
move(url: string, callback?: (err: Error, res: Response) => void): Test;
propfind(url: string, callback?: (err: Error, res: Response) => void): Test;
proppatch(url: string, callback?: (err: Error, res: Response) => void): Test;
unlock(url: string, callback?: (err: Error, res: Response) => void): Test;
report(url: string, callback?: (err: Error, res: Response) => void): Test;
mkactivity(url: string, callback?: (err: Error, res: Response) => void): Test;
checkout(url: string, callback?: (err: Error, res: Response) => void): Test;
merge(url: string, callback?: (err: Error, res: Response) => void): Test;
//m-search(url: string, callback?: (err: Error, res: Response) => void): Test;
notify(url: string, callback?: (err: Error, res: Response) => void): Test;
subscribe(url: string, callback?: (err: Error, res: Response) => void): Test;
unsubscribe(url: string, callback?: (err: Error, res: Response) => void): Test;
patch(url: string, callback?: (err: Error, res: Response) => void): Test;
search(url: string, callback?: (err: Error, res: Response) => void): Test;
connect(url: string, callback?: (err: Error, res: Response) => void): Test;
}
function agent(app?: any): supertest.TestAgent;
}
type CallbackHandler = { (err: any, res: supertest.Response): void; }|{ (res: supertest.Response): void; };
function supertest(app: any): 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;
}
interface Response extends superagent.Response {
}
}
export = supertest;
}