mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-20 12:00:53 +08:00
update typefiles
This commit is contained in:
Vendored
+2
@@ -79,6 +79,8 @@ declare module "superagent" {
|
||||
subscribe(url: string, callback?: (err: Error, res: Response) => void): Request;
|
||||
unsubscribe(url: string, callback?: (err: Error, res: Response) => void): Request;
|
||||
patch(url: string, callback?: (err: Error, res: Response) => void): Request;
|
||||
search(url: string, callback?: (err: Error, res: Response) => void): Request;
|
||||
connect(url: string, callback?: (err: Error, res: Response) => void): Request;
|
||||
parse(fn: Function): Request;
|
||||
saveCookies(res: Response): void;
|
||||
attachCookies(req: Request): void;
|
||||
|
||||
@@ -29,4 +29,31 @@ request
|
||||
req.expect(200, (err, res) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// cookie scenario, new version
|
||||
var client = supertest.agent(app);
|
||||
client
|
||||
.post('/login')
|
||||
.end((err, res) => {
|
||||
if (err) throw err;
|
||||
|
||||
client.get('/admin')
|
||||
.expect(200, (err, res) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
});
|
||||
|
||||
// functional expect
|
||||
supertest(app)
|
||||
.get('/')
|
||||
.expect(hasPreviousAndNextKeys)
|
||||
.end((err, res) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
function hasPreviousAndNextKeys(res: supertest.Response) {
|
||||
if (!('next' in res.body)) return "missing next key";
|
||||
if (!('prev' in res.body)) throw new Error("missing prev key");
|
||||
}
|
||||
|
||||
|
||||
Vendored
+38
-9
@@ -1,4 +1,4 @@
|
||||
// Type definitions for SuperTest 0.8.0
|
||||
// Type definitions for SuperTest 0.14.0
|
||||
// Project: https://github.com/visionmedia/supertest
|
||||
// Definitions by: Alex Varju <https://github.com/varju/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
@@ -12,19 +12,21 @@ declare 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;
|
||||
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;
|
||||
set(field: string, val: string): Test;
|
||||
set(field: Object): Test;
|
||||
query(val: Object): Test;
|
||||
send(data: string): Test;
|
||||
send(data: Object): Test;
|
||||
}
|
||||
interface Response extends superagent.Response {}
|
||||
|
||||
interface SuperTest {
|
||||
get(url: string): Test;
|
||||
@@ -52,7 +54,34 @@ declare module "supertest" {
|
||||
patch(url: string): Test;
|
||||
}
|
||||
|
||||
function agent(): superagent.Agent;
|
||||
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;
|
||||
}
|
||||
|
||||
function supertest(app: any): supertest.SuperTest;
|
||||
|
||||
Reference in New Issue
Block a user