mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-18 04:24:30 +08:00
Update SuperTest to version 1.1.0
- Callback now always takes 2 arguments, see https://github.com/visionmedia/superagent/commit/e440274 - Override superagent.Request.end() so it takes the proper callback signature
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
/// <reference path="supertest.d.ts" />
|
||||
/// <reference path="../express/express.d.ts" />
|
||||
|
||||
import supertest = require('supertest')
|
||||
import express = require('express');
|
||||
import * as supertest from 'supertest';
|
||||
import * as express from 'express';
|
||||
|
||||
var app = express();
|
||||
|
||||
@@ -11,7 +11,7 @@ supertest(app)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect('Content-Length', '20')
|
||||
.expect(201)
|
||||
.end((err: any, res: supertest.Response) => {
|
||||
.end((err, res) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
@@ -56,4 +56,3 @@ 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");
|
||||
}
|
||||
|
||||
|
||||
5
supertest/supertest.d.ts
vendored
5
supertest/supertest.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for SuperTest 0.14.0
|
||||
// Type definitions for SuperTest v1.1.0
|
||||
// Project: https://github.com/visionmedia/supertest
|
||||
// Definitions by: Alex Varju <https://github.com/varju/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
@@ -8,7 +8,7 @@
|
||||
declare module "supertest" {
|
||||
import superagent = require('superagent');
|
||||
|
||||
type CallbackHandler = { (err: any, res: supertest.Response): void; }|{ (res: supertest.Response): void; };
|
||||
type CallbackHandler = (err: any, res: supertest.Response) => void;
|
||||
|
||||
function supertest(app: any): supertest.SuperTest;
|
||||
|
||||
@@ -29,6 +29,7 @@ declare module "supertest" {
|
||||
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;
|
||||
}
|
||||
|
||||
interface Response extends superagent.Response {
|
||||
|
||||
Reference in New Issue
Block a user