-
Notifications
You must be signed in to change notification settings - Fork 0
/
app-controller-test.ts
31 lines (25 loc) · 1009 Bytes
/
app-controller-test.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
import { Test, TestingModule } from "@nestjs/testing";
import { expect } from "chai";
import "mocha";
import * as sinon from "sinon";
import { AppController } from "../src/app-controller";
import { AppModule } from "../src/app-module";
import { AppService } from "../src/app-service";
import { ConfigTestingModule } from "../src/config";
describe("AppController", () => {
let module: TestingModule;
beforeEach(async () => {
module = await Test.createTestingModule({
imports: [AppModule, ConfigTestingModule],
}).compile();
});
describe("root", () => {
it("should work", async () => {
const appService = module.get<AppService>(AppService);
const appController = module.get<AppController>(AppController);
const fake = sinon.fake.returns("Hello World - TEST");
sinon.replace(appService, "root", fake);
expect(await appController.root()).to.be.eql("Hello World - TEST");
});
});
});