-
-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
80 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}); |
65 changes: 33 additions & 32 deletions
65
integration/getting-started/src/controllers/calendars/CalendarsCtrl.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"}); | ||
}); | ||
}); | ||
|
||
}); | ||
}); |
3 changes: 2 additions & 1 deletion
3
integration/getting-started/test/integration/controllers/calendars/Calendars.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
], | ||
"exclude": [ | ||
"node_modules", | ||
"./public" | ||
"./public", | ||
"dist" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,4 +143,4 @@ | |
"packages": "packages", | ||
"test": "test" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters