mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 19:07:08 +00:00
Add superagent and supertest definitions
This commit is contained in:
parent
a58894f898
commit
edd97d5bd5
12
superagent/superagent-tests.ts
Normal file
12
superagent/superagent-tests.ts
Normal file
@ -0,0 +1,12 @@
|
||||
/// <reference path="superagent.d.ts" />
|
||||
|
||||
import superagent = require('superagent')
|
||||
|
||||
var agent = superagent.agent();
|
||||
agent
|
||||
.post('http://localhost:3000/signin')
|
||||
.send({ email: 'test@dummy.com', password: 'bacon' })
|
||||
.end((err, res) => {
|
||||
if (err) throw err;
|
||||
if (res.status !== 200) throw new Error('bad status ' + res.status);
|
||||
});
|
||||
84
superagent/superagent.d.ts
vendored
Normal file
84
superagent/superagent.d.ts
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
// Type definitions for SuperAgent 0.15.4
|
||||
// Project: https://github.com/visionmedia/superagent
|
||||
// Definitions by: Alex Varju <https://github.com/varju/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path='../node/node.d.ts' />
|
||||
|
||||
declare module "superagent" {
|
||||
export interface Response {
|
||||
text: string;
|
||||
body: Object;
|
||||
header: Object;
|
||||
type: string;
|
||||
charset: string;
|
||||
status: number;
|
||||
statusType: number;
|
||||
info: boolean;
|
||||
ok: boolean;
|
||||
redirect: boolean;
|
||||
clientError: boolean;
|
||||
serverError: boolean;
|
||||
error: any;
|
||||
accepted: boolean;
|
||||
noContent: boolean;
|
||||
badRequest: boolean;
|
||||
unauthorized: boolean;
|
||||
notAcceptable: boolean;
|
||||
notFound: boolean;
|
||||
forbidden: boolean;
|
||||
get(header: string): string;
|
||||
}
|
||||
|
||||
export interface Request {
|
||||
attach(field: string, file: string, filename: string): Request;
|
||||
redirects(n: number): Request;
|
||||
part(): Request;
|
||||
set(field: string, val: string): Request;
|
||||
set(field: Object): Request;
|
||||
get(field: string): string;
|
||||
type(val: string): Request;
|
||||
query(val: Object): Request;
|
||||
send(data: string): Request;
|
||||
send(data: Object): Request;
|
||||
write(data: string, encoding: string): boolean;
|
||||
write(data: NodeBuffer, encoding: string): boolean;
|
||||
pipe(stream: WritableStream, options?: Object): WritableStream;
|
||||
buffer(val: boolean): Request;
|
||||
timeout(ms: number): Request;
|
||||
clearTimeout(): Request;
|
||||
abort(): void;
|
||||
auth(user: string, name: string): Request;
|
||||
field(name: string, val: string): Request;
|
||||
end(callback?: (err: Error, res: Response) => void): Request;
|
||||
}
|
||||
|
||||
export interface Agent {
|
||||
get(url: string, callback?: (err: Error, res: Response) => void): Request;
|
||||
post(url: string, callback?: (err: Error, res: Response) => void): Request;
|
||||
put(url: string, callback?: (err: Error, res: Response) => void): Request;
|
||||
head(url: string, callback?: (err: Error, res: Response) => void): Request;
|
||||
del(url: string, callback?: (err: Error, res: Response) => void): Request;
|
||||
options(url: string, callback?: (err: Error, res: Response) => void): Request;
|
||||
trace(url: string, callback?: (err: Error, res: Response) => void): Request;
|
||||
copy(url: string, callback?: (err: Error, res: Response) => void): Request;
|
||||
lock(url: string, callback?: (err: Error, res: Response) => void): Request;
|
||||
mkcol(url: string, callback?: (err: Error, res: Response) => void): Request;
|
||||
move(url: string, callback?: (err: Error, res: Response) => void): Request;
|
||||
propfind(url: string, callback?: (err: Error, res: Response) => void): Request;
|
||||
proppatch(url: string, callback?: (err: Error, res: Response) => void): Request;
|
||||
unlock(url: string, callback?: (err: Error, res: Response) => void): Request;
|
||||
report(url: string, callback?: (err: Error, res: Response) => void): Request;
|
||||
mkactivity(url: string, callback?: (err: Error, res: Response) => void): Request;
|
||||
checkout(url: string, callback?: (err: Error, res: Response) => void): Request;
|
||||
merge(url: string, callback?: (err: Error, res: Response) => void): Request;
|
||||
//m-search(url: string, callback?: (err: Error, res: Response) => void): Request;
|
||||
notify(url: string, callback?: (err: Error, res: Response) => void): Request;
|
||||
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;
|
||||
parse(fn: Function): Request;
|
||||
}
|
||||
|
||||
export function agent(): Agent;
|
||||
}
|
||||
16
supertest/supertest-tests.ts
Normal file
16
supertest/supertest-tests.ts
Normal 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
supertest/supertest.d.ts
vendored
Normal file
53
supertest/supertest.d.ts
vendored
Normal 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;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user