From 4e8f64ac891606dd48ec1aac579e43ca37f4c274 Mon Sep 17 00:00:00 2001 From: "Remo H. Jansen" Date: Thu, 6 Jul 2017 22:25:43 +0100 Subject: [PATCH] Updated dependencies (#56) --- .gitignore | 1 + package.json | 8 +-- test/bugs.test.ts | 15 +++--- test/decorators.test.ts | 2 +- test/framework.test.ts | 114 ++++++++++++++++++++-------------------- test/server.test.ts | 14 ++--- 6 files changed, 79 insertions(+), 75 deletions(-) diff --git a/.gitignore b/.gitignore index c075abfa..29a59a3f 100644 --- a/.gitignore +++ b/.gitignore @@ -63,3 +63,4 @@ test/**/*.js type_definitions/**/*.js type_definitions/*.js +package-lock.json diff --git a/package.json b/package.json index c6949abe..d574e4a4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "inversify-express-utils", - "version": "3.5.2", + "version": "4.0.0", "description": "Some utilities for the development of express applications with Inversify", "main": "lib/index.js", "jsnext:main": "es/index.js", @@ -37,8 +37,8 @@ "cookie-parser": "^1.4.3", "gulp": "^3.9.1", "gulp-istanbul": "^1.1.1", - "gulp-mocha": "^4.0.1", - "gulp-tslint": "^7.0.1", + "gulp-mocha": "3.0.1", + "gulp-tslint": "^8.1.1", "gulp-typescript": "^3.1.3", "inversify": "^4.0.0", "mocha": "^3.2.0", @@ -49,7 +49,7 @@ "source-map-support": "^0.4.6", "supertest": "^3.0.0", "tslint": "^5.0.0", - "typescript": "^2.1.1" + "typescript": "^2.4.1" }, "dependencies": { "express": "^4.14.1" diff --git a/test/bugs.test.ts b/test/bugs.test.ts index c16e78e0..08bef12d 100644 --- a/test/bugs.test.ts +++ b/test/bugs.test.ts @@ -1,13 +1,15 @@ import { expect } from "chai"; import * as express from "express"; -import { controller, httpMethod, httpGet, request, response, requestParam, - queryParam } from "../src/decorators"; import { interfaces } from "../src/interfaces"; import { METADATA_KEY, PARAMETER_TYPE } from "../src/constants"; import { InversifyExpressServer } from "../src/server"; import { Container, injectable } from "inversify"; import { TYPE } from "../src/constants"; import * as supertest from "supertest"; +import { + controller, httpMethod, httpGet, request, + response, requestParam, queryParam +} from "../src/decorators"; describe("Unit Test: Previous bugs", () => { @@ -53,8 +55,8 @@ describe("Unit Test: Previous bugs", () => { .expect(200) .then(response1 => { expect(Array.isArray(response1.body)).to.eql(true); - expect(response1.body[0].id).to.eql("1"); - expect(response1.body[0].id).to.eql("2"); + expect(response1.body[0].id).to.eql(1); + expect(response1.body[1].id).to.eql(2); }); supertest(app).get("/api/test/5") @@ -67,7 +69,8 @@ describe("Unit Test: Previous bugs", () => { }); }); - it("should support empty query params", (done) => { + + it("should support empty query params", (done) => { let container = new Container(); @injectable() @@ -94,7 +97,7 @@ describe("Unit Test: Previous bugs", () => { .expect(200) .then(response1 => { expect(response1.body.test).to.eql("testquery"); - expect(response1.body.empty).to.be.undefined; + expect(response1.body.empty).to.eq(undefined); done(); }); diff --git a/test/decorators.test.ts b/test/decorators.test.ts index 29753626..4b7d4884 100644 --- a/test/decorators.test.ts +++ b/test/decorators.test.ts @@ -69,7 +69,7 @@ describe("Unit Test: Controller Decorators", () => { } let methodMetadataList: interfaces.ControllerParameterMetadata = Reflect.getMetadata(METADATA_KEY.controllerParameter, TestController); - expect(methodMetadataList.hasOwnProperty("test")).true; + expect(methodMetadataList.hasOwnProperty("test")).to.eqls(true); let paramaterMetadataList: interfaces.ParameterMetadata[] = methodMetadataList[methodName]; expect(paramaterMetadataList.length).eql(2); diff --git a/test/framework.test.ts b/test/framework.test.ts index 8b80682f..420bdcac 100644 --- a/test/framework.test.ts +++ b/test/framework.test.ts @@ -64,12 +64,12 @@ describe("Integration Tests:", () => { }); - it ("should work for methods which call next()", (done) => { + it ("should work for methods which call nextFunc()", (done) => { @injectable() @controller("/") class TestController { - @httpGet("/") public getTest(req: express.Request, res: express.Response, next: express.NextFunction) { - next(); + @httpGet("/") public getTest(req: express.Request, res: express.Response, nextFunc: express.NextFunction) { + nextFunc(); } @httpGet("/") public getTest2(req: express.Request, res: express.Response) { @@ -85,14 +85,14 @@ describe("Integration Tests:", () => { }); - it ("should work for async methods which call next()", (done) => { + it ("should work for async methods which call nextFunc()", (done) => { @injectable() @controller("/") class TestController { - @httpGet("/") public getTest(req: express.Request, res: express.Response, next: express.NextFunction) { + @httpGet("/") public getTest(req: express.Request, res: express.Response, nextFunc: express.NextFunction) { return new Promise(((resolve) => { setTimeout(() => { - next(); + nextFunc(); resolve(); }, 100, "GET"); })); @@ -111,12 +111,12 @@ describe("Integration Tests:", () => { }); - it ("should work for async methods called by next()", (done) => { + it ("should work for async methods called by nextFunc()", (done) => { @injectable() @controller("/") class TestController { - @httpGet("/") public getTest(req: express.Request, res: express.Response, next: express.NextFunction) { - next(); + @httpGet("/") public getTest(req: express.Request, res: express.Response, nextFunc: express.NextFunction) { + nextFunc(); } @httpGet("/") public getTest2(req: express.Request, res: express.Response) { @@ -251,17 +251,17 @@ describe("Integration Tests:", () => { describe("Middleware:", () => { let result: string; let middleware: any = { - a: function (req: express.Request, res: express.Response, next: express.NextFunction) { + a: function (req: express.Request, res: express.Response, nextFunc: express.NextFunction) { result += "a"; - next(); + nextFunc(); }, - b: function (req: express.Request, res: express.Response, next: express.NextFunction) { + b: function (req: express.Request, res: express.Response, nextFunc: express.NextFunction) { result += "b"; - next(); + nextFunc(); }, - c: function (req: express.Request, res: express.Response, next: express.NextFunction) { + c: function (req: express.Request, res: express.Response, nextFunc: express.NextFunction) { result += "c"; - next(); + nextFunc(); } }; let spyA = sinon.spy(middleware, "a"); @@ -289,9 +289,9 @@ describe("Integration Tests:", () => { agent.get("/") .expect(200, "GET", function () { - expect(spyA.calledOnce).to.be.true; - expect(spyB.calledOnce).to.be.true; - expect(spyC.calledOnce).to.be.true; + expect(spyA.calledOnce).to.eqls(true); + expect(spyB.calledOnce).to.eqls(true); + expect(spyC.calledOnce).to.eqls(true); expect(result).to.equal("abc"); done(); }); @@ -310,9 +310,9 @@ describe("Integration Tests:", () => { agent.post("/") .expect(200, "POST", function () { - expect(spyA.calledOnce).to.be.true; - expect(spyB.calledOnce).to.be.true; - expect(spyC.calledOnce).to.be.true; + expect(spyA.calledOnce).to.eqls(true); + expect(spyB.calledOnce).to.eqls(true); + expect(spyC.calledOnce).to.eqls(true); expect(result).to.equal("abc"); done(); }); @@ -331,9 +331,9 @@ describe("Integration Tests:", () => { agent.put("/") .expect(200, "PUT", function () { - expect(spyA.calledOnce).to.be.true; - expect(spyB.calledOnce).to.be.true; - expect(spyC.calledOnce).to.be.true; + expect(spyA.calledOnce).to.eqls(true); + expect(spyB.calledOnce).to.eqls(true); + expect(spyC.calledOnce).to.eqls(true); expect(result).to.equal("abc"); done(); }); @@ -352,9 +352,9 @@ describe("Integration Tests:", () => { agent.patch("/") .expect(200, "PATCH", function () { - expect(spyA.calledOnce).to.be.true; - expect(spyB.calledOnce).to.be.true; - expect(spyC.calledOnce).to.be.true; + expect(spyA.calledOnce).to.eqls(true); + expect(spyB.calledOnce).to.eqls(true); + expect(spyC.calledOnce).to.eqls(true); expect(result).to.equal("abc"); done(); }); @@ -373,9 +373,9 @@ describe("Integration Tests:", () => { agent.head("/") .expect(200, "HEAD", function () { - expect(spyA.calledOnce).to.be.true; - expect(spyB.calledOnce).to.be.true; - expect(spyC.calledOnce).to.be.true; + expect(spyA.calledOnce).to.eqls(true); + expect(spyB.calledOnce).to.eqls(true); + expect(spyC.calledOnce).to.eqls(true); expect(result).to.equal("abc"); done(); }); @@ -394,9 +394,9 @@ describe("Integration Tests:", () => { agent.delete("/") .expect(200, "DELETE", function () { - expect(spyA.calledOnce).to.be.true; - expect(spyB.calledOnce).to.be.true; - expect(spyC.calledOnce).to.be.true; + expect(spyA.calledOnce).to.eqls(true); + expect(spyB.calledOnce).to.eqls(true); + expect(spyC.calledOnce).to.eqls(true); expect(result).to.equal("abc"); done(); }); @@ -415,9 +415,9 @@ describe("Integration Tests:", () => { agent.get("/") .expect(200, "ALL", function () { - expect(spyA.calledOnce).to.be.true; - expect(spyB.calledOnce).to.be.true; - expect(spyC.calledOnce).to.be.true; + expect(spyA.calledOnce).to.eqls(true); + expect(spyB.calledOnce).to.eqls(true); + expect(spyC.calledOnce).to.eqls(true); expect(result).to.equal("abc"); done(); }); @@ -436,9 +436,9 @@ describe("Integration Tests:", () => { supertest(server.build()) .get("/") .expect(200, "GET", function () { - expect(spyA.calledOnce).to.be.true; - expect(spyB.calledOnce).to.be.true; - expect(spyC.calledOnce).to.be.true; + expect(spyA.calledOnce).to.eqls(true); + expect(spyB.calledOnce).to.eqls(true); + expect(spyC.calledOnce).to.eqls(true); expect(result).to.equal("abc"); done(); }); @@ -464,9 +464,9 @@ describe("Integration Tests:", () => { supertest(server.build()) .get("/") .expect(200, "GET", function () { - expect(spyA.calledOnce).to.be.true; - expect(spyB.calledOnce).to.be.true; - expect(spyC.calledOnce).to.be.true; + expect(spyA.calledOnce).to.eqls(true); + expect(spyB.calledOnce).to.eqls(true); + expect(spyC.calledOnce).to.eqls(true); expect(result).to.equal("abc"); done(); }); @@ -490,9 +490,9 @@ describe("Integration Tests:", () => { supertest(server.build()) .get("/") .expect(200, "GET", function () { - expect(spyA.calledOnce).to.be.true; - expect(spyB.calledOnce).to.be.true; - expect(spyC.calledOnce).to.be.true; + expect(spyA.calledOnce).to.eqls(true); + expect(spyB.calledOnce).to.eqls(true); + expect(spyC.calledOnce).to.eqls(true); expect(result).to.equal("abc"); done(); }); @@ -519,8 +519,8 @@ describe("Integration Tests:", () => { return agent.get("/") .expect(200, "GET") .then(() => { - expect(spyA.calledOnce).to.be.true; - expect(spyB.calledOnce).to.be.true; + expect(spyA.calledOnce).to.eqls(true); + expect(spyB.calledOnce).to.eqls(true); expect(result).to.equal("ab"); }); }); @@ -547,8 +547,8 @@ describe("Integration Tests:", () => { return agent.get("/") .expect(200, "GET") .then(() => { - expect(spyA.calledOnce).to.be.true; - expect(spyB.calledOnce).to.be.true; + expect(spyA.calledOnce).to.eqls(true); + expect(spyB.calledOnce).to.eqls(true); expect(result).to.equal("ab"); }); }); @@ -575,8 +575,8 @@ describe("Integration Tests:", () => { return agent.get("/") .expect(200, "GET") .then(() => { - expect(spyA.calledOnce).to.be.true; - expect(spyB.calledOnce).to.be.true; + expect(spyA.calledOnce).to.eqls(true); + expect(spyB.calledOnce).to.eqls(true); expect(result).to.equal("ab"); }); }); @@ -652,8 +652,8 @@ describe("Integration Tests:", () => { @injectable() @controller("/") class TestController { - @httpPost("/") public getTest(@requestBody() body: string) { - return body; + @httpPost("/") public getTest(@requestBody() reqBody: string) { + return reqBody; } } container.bind(TYPE.Controller).to(TestController).whenTargetNamed("TestController"); @@ -703,9 +703,9 @@ describe("Integration Tests:", () => { server = new InversifyExpressServer(container); server.setConfig((app) => { app.use(cookieParser()); - app.use(function (req, res, next) { + app.use(function (req, res, nextFunc) { res.cookie("cookie", "hey"); - next(); + nextFunc(); }); }); supertest(server.build()) @@ -717,9 +717,9 @@ describe("Integration Tests:", () => { @injectable() @controller("/") class TestController { - @httpGet("/") public getTest(@next() next: any) { + @httpGet("/") public getTest(@next() nextFunc: any) { let err = new Error("foo"); - return next(); + return nextFunc(); } @httpGet("/") public getResult() { return "foo"; diff --git a/test/server.test.ts b/test/server.test.ts index 04ac6924..fe2f9bae 100644 --- a/test/server.test.ts +++ b/test/server.test.ts @@ -25,14 +25,14 @@ describe("Unit Test: InversifyExpressServer", () => { server.setConfig(configFn) .setErrorConfig(errorConfigFn); - expect(configFn.called).to.be.false; - expect(errorConfigFn.called).to.be.false; + expect(configFn.called).to.eq(false); + expect(errorConfigFn.called).to.eq(false); server.build(); - expect(configFn.calledOnce).to.be.true; - expect(errorConfigFn.calledOnce).to.be.true; - expect(configFn.calledBefore(errorConfigFn)).to.be.true; + expect(configFn.calledOnce).to.eqls(true); + expect(errorConfigFn.calledOnce).to.eqls(true); + expect(configFn.calledBefore(errorConfigFn)).to.eqls(true); done(); }); @@ -49,8 +49,8 @@ describe("Unit Test: InversifyExpressServer", () => { let serverWithDefaultRouter = new InversifyExpressServer(container); let serverWithCustomRouter = new InversifyExpressServer(container, customRouter); - expect((serverWithDefaultRouter as any)._router === customRouter).to.be.false; - expect((serverWithCustomRouter as any)._router === customRouter).to.be.true; + expect((serverWithDefaultRouter as any)._router === customRouter).to.eq(false); + expect((serverWithCustomRouter as any)._router === customRouter).to.eqls(true); });