Skip to content

Commit

Permalink
Updated dependencies (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
remojansen authored Jul 6, 2017
1 parent a55234b commit 4e8f64a
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 75 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@ test/**/*.js

type_definitions/**/*.js
type_definitions/*.js
package-lock.json
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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"
Expand Down
15 changes: 9 additions & 6 deletions test/bugs.test.ts
Original file line number Diff line number Diff line change
@@ -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", () => {

Expand Down Expand Up @@ -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")
Expand All @@ -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()
Expand All @@ -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();
});

Expand Down
2 changes: 1 addition & 1 deletion test/decorators.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
114 changes: 57 additions & 57 deletions test/framework.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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");
}));
Expand All @@ -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) {
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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();
});
Expand All @@ -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();
});
Expand All @@ -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();
});
Expand All @@ -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();
});
Expand All @@ -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();
});
Expand All @@ -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();
});
Expand All @@ -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();
});
Expand All @@ -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();
});
Expand All @@ -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();
});
Expand All @@ -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();
});
Expand All @@ -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");
});
});
Expand All @@ -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");
});
});
Expand All @@ -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");
});
});
Expand Down Expand Up @@ -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<interfaces.Controller>(TYPE.Controller).to(TestController).whenTargetNamed("TestController");
Expand Down Expand Up @@ -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())
Expand All @@ -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";
Expand Down
14 changes: 7 additions & 7 deletions test/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand All @@ -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);

});

Expand Down

0 comments on commit 4e8f64a

Please sign in to comment.