Add superagent and supertest definitions

This commit is contained in:
Alex Varju
2013-09-05 15:44:29 -07:00
parent a58894f898
commit edd97d5bd5
4 changed files with 165 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
/// <reference path="supertest.d.ts" />
/// <reference path="../express/express.d.ts" />
import supertest = require('supertest')
import express = require('express');
var app = express();
supertest(app)
.get('/user')
.expect('Content-Type', /json/)
.expect('Content-Length', '20')
.expect(201)
.end((err, res) => {
if (err) throw err;
});
+53
View File
@@ -0,0 +1,53 @@
// Type definitions for SuperTest 0.8.0
// Project: https://github.com/visionmedia/supertest
// Definitions by: Alex Varju <https://github.com/varju/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path='../superagent/superagent.d.ts' />
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: superagent.Response) => void): Test;
expect(status: number, body: string, callback?: (err: Error, res: superagent.Response) => void): Test;
expect(body: string, callback?: (err: Error, res: superagent.Response) => void): Test;
expect(body: RegExp, callback?: (err: Error, res: superagent.Response) => void): Test;
expect(body: Object, callback?: (err: Error, res: superagent.Response) => void): Test;
expect(field: string, val: string, callback?: (err: Error, res: superagent.Response) => void): Test;
expect(field: string, val: RegExp, callback?: (err: Error, res: superagent.Response) => void): Test;
}
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;
}
}
function supertest(app: any): supertest.SuperTest;
export = supertest;
}