From 15852a714521bb27a8b4e129c7f48e7e1046cfdb Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Tue, 24 Nov 2015 11:27:45 +0100 Subject: [PATCH] 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 --- supertest/supertest-tests.ts | 7 +++---- supertest/supertest.d.ts | 5 +++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/supertest/supertest-tests.ts b/supertest/supertest-tests.ts index d76c97ea48..5e0de8ad8c 100644 --- a/supertest/supertest-tests.ts +++ b/supertest/supertest-tests.ts @@ -1,8 +1,8 @@ /// /// -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"); } - diff --git a/supertest/supertest.d.ts b/supertest/supertest.d.ts index dccbd47c8b..9ca154e2f5 100644 --- a/supertest/supertest.d.ts +++ b/supertest/supertest.d.ts @@ -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 // 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 {