本文整理汇总了TypeScript中@tsed/testing.TestContext类的典型用法代码示例。如果您正苦于以下问题:TypeScript TestContext类的具体用法?TypeScript TestContext怎么用?TypeScript TestContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestContext类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe("Calendars", () => {
// bootstrap your expressApplication in first
before(TestContext.bootstrap(Server));
before(TestContext.inject([ExpressApplication], (expressApplication: ExpressApplication) => {
this.app = expressApplication;
}));
after(TestContext.reset);
// then run your test
describe("GET /rest/calendars", () => {
it("should return all calendars", (done) => {
SuperTest(this.app)
.get("/rest/calendars")
.expect(200)
.end((err, response: any) => {
if (err) {
throw (err);
}
let obj = JSON.parse(response.text);
expect(obj).to.be.an("array");
done();
});
});
});
});
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:31,代码来源:Calendars.spec.ts
示例2: describe
describe("Upload", () => {
// bootstrap the express application
before(TestContext.bootstrap(Server));
before(TestContext.inject([ExpressApplication], (expressApplication: ExpressApplication) => {
this.app = expressApplication;
}));
after(TestContext.reset);
describe("PUT /rest/upload", () => { // work if you enable the MultipartFileMiddlewareOverrided ;)
it("should return 400", (done) => {
SuperTest(this.app)
.put("/rest/upload")
.attach("file", Path.join(__dirname, "/test.txt"))
.expect(400)
.end((err, res: any) => {
if (err) {
throw (err);
}
expect(res.text).to.eq("This should be thrown and seen on the test failure.");
done();
});
});
});
});
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:27,代码来源:UploadCtrl.spec.ts
示例3: it
it("should call attach method", inject([ServerSettingsService], async (serverSettingsService: ServerSettingsService) => {
// GIVEN
const socketIOServer = {attach: Sinon.stub(), adapter: Sinon.stub()};
const httpServer = {type: "http", get: Sinon.stub().returns("httpServer")};
const httpsServer = {type: "https", get: Sinon.stub().returns("httpsServer")};
const socketIOService = {addSocketProvider: Sinon.stub()};
serverSettingsService.set("socketIO", {config: "config"});
serverSettingsService.set("http", false);
const socketIOModule = TestContext.invoke(SocketIOModule, [
{provide: HttpServer, use: httpServer},
{provide: HttpsServer, use: httpsServer},
{provide: SocketIOServer, use: socketIOServer},
{provide: SocketIOService, use: socketIOService}
]);
this.getWebsocketServicesStub.returns([{provider: "provider"}]);
// WHEN
await socketIOModule.$onServerReady();
socketIOServer.attach.should.have.been.calledWithExactly(httpsServer, {
config: "config"
});
this.getWebsocketServicesStub.should.have.been.calledWithExactly();
socketIOService.addSocketProvider.should.have.been.calledWithExactly({provider: "provider"});
}));
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:28,代码来源:SocketIOModule.spec.ts
示例4: after
after(() => {
TestContext.reset();
sandbox.restore();
});
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:4,代码来源:GraphQLService.spec.ts
示例5: after
after(() => {
TestContext.reset();
this.getWebsocketServicesStub.restore();
this.printSocketEventsStub.restore();
});
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:5,代码来源:SocketIOModule.spec.ts
示例6: after
after(() => {
TestContext.reset();
this.connectStub.restore();
});
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:4,代码来源:TypeORMService.spec.ts
示例7: inject
inject([ServerSettingsService], (settings: ServerSettingsService) => {
settings.set("typeorm", {});
this.createConnectionStub.restore();
TestContext.reset();
})
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:5,代码来源:TypeORMModule.spec.ts
注:本文中的@tsed/testing.TestContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论