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:
Tanguy Krotoff
2015-11-24 11:27:45 +01:00
parent b30dbc4dd3
commit 15852a7145
2 changed files with 6 additions and 6 deletions

View File

@@ -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");
}

View File

@@ -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 {