Skip to content

Commit

Permalink
fix: fix compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
Romakita committed Dec 31, 2018
1 parent 886472c commit b2173a3
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 122 deletions.
1 change: 1 addition & 0 deletions .nycrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"**/*.d.ts",
"node_modules",
"packages/**/*.spec.ts",
"integration",
"**/interfaces/**",
"**/legacy/**",
"**/index.ts"
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Starters

* [Quick start project](https://github.com/Romakita/example-ts-express-decorator/tree/4.0.0/example-basic)
* [Quick start project](https://github.com/Romakita/ts-express-decorators/tree/production/integration/getting-started)
* [Node Api Starter](https://github.com/scopsy/node-typescript-starter) by [Scopsy](https://github.com/scopsy)

## Demo
Expand All @@ -11,7 +11,7 @@ Some examples are available along these links :

**Projects examples for v4.0.0 and more**

* [Basics usages](https://github.com/Romakita/example-ts-express-decorator/tree/4.0.0/example-basic)
* [Basics usages](https://github.com/Romakita/ts-express-decorators/tree/production/integration/getting-started)
* [Https](https://github.com/Romakita/example-ts-express-decorator/tree/4.0.0/example-https)
* [Authentication with Passport.js](https://github.com/Romakita/example-ts-express-decorator/tree/4.0.0/example-passport)
* [Mongoose & Swagger](https://github.com/Romakita/example-ts-express-decorator/tree/4.0.0/example-mongoose)
Expand Down
18 changes: 10 additions & 8 deletions integration/getting-started/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
"clean": "rimraf '{src,test}/**/*.{js,js.map}'",
"build": "npm run tsc",
"postinstall": "npm run build",
"tslint": "tslint ./*.ts ./lib/*.ts",
"test": "npm run clean && npm run tsc && npm run tslint && npm run nyc",
"nyc": "NODE_ENV=test nyc --reporter=html --reporter=text _mocha \"{src,test}/**/*.spec.js\" --recursive",
"coveralls:travis": "nyc report --reporter=text-lcov | coveralls",
"test": "npm run test:lint && npm run test:unit",
"test:unit": "cross-env NODE_ENV=test nyc --reporter=html --reporter=text mocha --recursive",
"test:lint": "tslint --project tsconfig.json",
"test:lint:fix": "tslint --project tsconfig.json --fix",
"travis:deploy-once": "travis-deploy-once",
"travis:coveralls": "nyc report --reporter=text-lcov | coveralls",
"tsc": "tsc --project tsconfig.json",
"tsc:w": "tsc --project tsconfig.json -w",
"start:dev": "nodemon --watch 'src/**/*.ts' --ignore 'node_modules/**/*' --exec ts-node src/index.ts",
Expand All @@ -19,10 +21,10 @@
"author": "",
"license": "MIT",
"dependencies": {
"@tsed/common": "^5.0.0",
"@tsed/core": "^5.0.0",
"@tsed/swagger": "^5.0.0",
"@tsed/testing": "^5.0.0",
"@tsed/common": "^5.0.6",
"@tsed/core": "^5.0.6",
"@tsed/swagger": "^5.0.6",
"@tsed/testing": "^5.0.6",
"@types/swagger-schema-official": "^2.0.9",
"body-parser": "^1.18.3",
"compression": "^1.7.1",
Expand Down
12 changes: 12 additions & 0 deletions integration/getting-started/scripts/mocha/register.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const Chai = require("chai");
const ChaiAsPromised = require("chai-as-promised");
const SinonChai = require("sinon-chai");

Chai.should();
Chai.use(SinonChai);
Chai.use(ChaiAsPromised);

process.on("unhandledRejection", (reason, p) => {
console.log("Unhandled Rejection at: Promise", p, "reason:", reason);
// application specific logging, throwing an error, or other logic here
});
Original file line number Diff line number Diff line change
@@ -1,53 +1,54 @@
import {ControllerService} from "@tsed/common";
import {inject} from "@tsed/testing";
import {expect, Sinon} from "../../../test/tools";
import {CalendarsService} from "../../services/calendars/CalendarsService";
import {MemoryStorage} from "../../services/storage/MemoryStorage";
import {CalendarsCtrl} from "./CalendarsCtrl";
import {expect} from "chai";


describe("CalendarsCtrl", () => {

describe("without IOC", () => {
before(() => {
this.calendarsCtrl = new CalendarsCtrl(new CalendarsService(new MemoryStorage()));
});
describe("without IOC", () => {
before(() => {
this.calendarsCtrl = new CalendarsCtrl(new CalendarsService(new MemoryStorage()));
});

it("should do something", () => {
expect(this.calendarsCtrl).to.be.an.instanceof(CalendarsCtrl);
});
it("should do something", () => {
expect(this.calendarsCtrl).to.be.an.instanceof(CalendarsCtrl);
});
});

describe("via InjectorService to mock other service", () => {
before(inject([ControllerService], (controllerService: ControllerService) => {
describe("via InjectorService to mock other service", () => {
before(inject([ControllerService], (controllerService: ControllerService) => {

this.calendarsService = {
find: Sinon.stub().returns(Promise.resolve({id: "1"}))
};
var Sinon;
this.calendarsService = {
find: Sinon.stub().returns(Promise.resolve({id: "1"}))
};

const locals = new Map<any, any>();
locals.set(CalendarsService, this.calendarsService);
const locals = new Map<any, any>();
locals.set(CalendarsService, this.calendarsService);

this.CalendarsCtrl = controllerService.invoke<CalendarsCtrl>(CalendarsCtrl, locals);
this.result = this.CalendarsCtrl.get("1");
return this.result;
}));
this.CalendarsCtrl = controllerService.invoke<CalendarsCtrl>(CalendarsCtrl, locals);
this.result = this.CalendarsCtrl.get("1");
return this.result;
}));

it("should get the service from InjectorService", () => {
expect(this.CalendarsCtrl).to.be.an.instanceof(CalendarsCtrl);
});
it("should get the service from InjectorService", () => {
expect(this.CalendarsCtrl).to.be.an.instanceof(CalendarsCtrl);
});

it("should have a fake memoryStorage", () => {
expect(this.CalendarsCtrl.calendarsService).to.equal(this.calendarsService);
});
it("should have a fake memoryStorage", () => {
expect(this.CalendarsCtrl.calendarsService).to.equal(this.calendarsService);
});

it("should have been called the CalendarService.find() method", () => {
this.calendarsService.find.should.be.calledWithExactly("1");
});
it("should have been called the CalendarService.find() method", () => {
this.calendarsService.find.should.be.calledWithExactly("1");
});

it("should return the calendar", () => {
return this.result.should.eventually.deep.equal({id: "1"});
});
it("should return the calendar", () => {
return this.result.should.eventually.deep.equal({id: "1"});
});
});

});
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {ExpressApplication} from "@tsed/common";
import {TestContext} from "@tsed/testing";
import {expect} from "chai";
import * as SuperTest from "supertest";
import {Server} from "../../../../src/Server";
import {expect} from "../../../tools";


describe("Calendars", () => {

Expand Down
5 changes: 5 additions & 0 deletions integration/getting-started/test/mocha.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
--require ts-node/register
--require tsconfig-paths/register
--require scripts/mocha/register
--bail
{src,test}/**/*.spec.ts
71 changes: 0 additions & 71 deletions integration/getting-started/test/tools.ts

This file was deleted.

3 changes: 2 additions & 1 deletion integration/getting-started/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
],
"exclude": [
"node_modules",
"./public"
"./public",
"dist"
]
}
8 changes: 4 additions & 4 deletions integration/getting-started/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
dependencies:
samsam "1.3.0"

"@tsed/common@5.0.6", "@tsed/common@^5.0.0":
"@tsed/common@5.0.6", "@tsed/common@^5.0.6":
version "5.0.6"
resolved "https://registry.yarnpkg.com/@tsed/common/-/common-5.0.6.tgz#5b7d8c669523627a72df78424e2918fb35a1e8b7"
integrity sha512-wlfXNBuImVa1S01jtOaD+fFBrJmdEi58deprqFAjyf5hrX8faLxARmRRR85LHPClBuHImn774U8ASBBjYQn8sg==
Expand All @@ -113,7 +113,7 @@
ts-log-debug "^4.0.1"
tslib "^1.9.0"

"@tsed/core@5.0.6", "@tsed/core@^5.0.0":
"@tsed/core@5.0.6", "@tsed/core@^5.0.6":
version "5.0.6"
resolved "https://registry.yarnpkg.com/@tsed/core/-/core-5.0.6.tgz#96a345d23e6a6cde3e215ee0d0dff0ac5d7b2fd3"
integrity sha512-O75Gv66cgoiHOpr3DZloYdbHNTAwGrStPJKGChn7xU89VMmsI6NAw29UU8cfPApPMCkcYkroEUl6S05ig2QCBw==
Expand All @@ -130,7 +130,7 @@
"@tsed/core" "5.0.6"
tslib "^1.8.0"

"@tsed/swagger@^5.0.0":
"@tsed/swagger@^5.0.6":
version "5.0.6"
resolved "https://registry.yarnpkg.com/@tsed/swagger/-/swagger-5.0.6.tgz#42e467bfee0b3bd62dd6a6394640154c56a5c82c"
integrity sha512-C5ytJwci2tEpZU8XP3LeKRxx3qWiERhxXLIBs2ERw9uzDerqoPmobxhCgETUYxAr4WDRwiZ6oamaUSRHe/r4Og==
Expand All @@ -140,7 +140,7 @@
swagger-ui-dist "^3.13.6"
tslib "^1.9.0"

"@tsed/testing@^5.0.0":
"@tsed/testing@^5.0.6":
version "5.0.6"
resolved "https://registry.yarnpkg.com/@tsed/testing/-/testing-5.0.6.tgz#4667889773efd9b2b37dcd4f8603203c8d4fdb7c"
integrity sha512-OM2nGbQxrPL1Dg3YlJfeBn2roJRrd58TF8ne2pNm6VLSRHKFCOta5E2aO5MhBL9taOj/Wh6CNHkNV6yNQvOYVg==
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,4 @@
"packages": "packages",
"test": "test"
}
}
}
10 changes: 8 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
"./**/*.spec.ts",
"test",
"lib",
"dist"
]
"dist",
"integration/**"
],
"linterOptions": {
"exclude": [
"integration/**"
]
}
}

0 comments on commit b2173a3

Please sign in to comment.