當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript testing.TestContext類代碼示例

本文整理匯總了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;未經允許,請勿轉載。