-
-
Notifications
You must be signed in to change notification settings - Fork 281
/
PlatformExpress.spec.ts
58 lines (52 loc) · 1.63 KB
/
PlatformExpress.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import {PlatformApplication, PlatformHandler, PlatformRequest, PlatformResponse, PlatformRouter} from "@tsed/common";
import {
PlatformExpressApplication,
PlatformExpressHandler,
PlatformExpressRequest,
PlatformExpressResponse,
PlatformExpressRouter
} from "@tsed/platform-express";
import {expect} from "chai";
import Sinon from "sinon";
import {stub} from "../../../../../test/helper/tools";
import {PlatformExpress} from "./PlatformExpress";
const sandbox = Sinon.createSandbox();
describe("PlatformExpress", () => {
beforeEach(() => {
sandbox.stub(PlatformExpress, "build");
});
afterEach(() => {
sandbox.restore();
});
it("should create the platform", async () => {
class Test {}
const platform = {bootstrap: sandbox.stub().returnsThis(), useProviders: sandbox.stub().returnsThis()};
stub(PlatformExpress.build).returns(platform);
await PlatformExpress.bootstrap(Test, {});
await PlatformExpress.bootstrap(Test);
expect(PlatformExpress.build).to.have.been.calledWithExactly(PlatformExpress, Test, {});
expect(platform.bootstrap).to.have.been.calledWithExactly();
expect(PlatformExpress.providers).to.deep.equal([
{
provide: PlatformApplication,
useClass: PlatformExpressApplication
},
{
provide: PlatformRouter,
useClass: PlatformExpressRouter
},
{
provide: PlatformHandler,
useClass: PlatformExpressHandler
},
{
provide: PlatformResponse,
useClass: PlatformExpressResponse
},
{
provide: PlatformRequest,
useClass: PlatformExpressRequest
}
]);
});
});