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


TypeScript proxyquire.load函數代碼示例

本文整理匯總了TypeScript中proxyquire.load函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript load函數的具體用法?TypeScript load怎麽用?TypeScript load使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了load函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: getDatabaseDetails

        return Promise.all(_.map([DB1, DB2], (db: string) => {
          let error: Error;

          function getDatabaseDetails(req: DatabaseDetailsRequest): Promise<DatabaseDetailsResponseMessage> {
            return new Promise((resolve, reject) => {
              assert.deepEqual(state.databaseInfo.databaseDetails[req.database], { inFlight: true, valid: false });
              error = new Error();
              reject(error);
            });
          }

          databasesMocked = proxyquire.load("./databaseInfo", {
            "../util/api": {
              getDatabaseDetails,
            },
          });

          return databasesMocked.refreshDatabaseDetails(db)(dispatch, () => state).then(() => {
            assert.deepEqual(state.databaseInfo.databaseDetails[db], {
              inFlight: false,
              valid: false,
              lastError: error,
            });
          });
        }));
開發者ID:codepope,項目名稱:cockroach,代碼行數:25,代碼來源:databaseInfo.spec.ts

示例2: getTableDetails

        return Promise.all(_.map(tableList, (id: TableID) => {
          let response: TableDetailsResponse;

          function getTableDetails(req: TableDetailsRequest): Promise<TableDetailsResponseMessage> {
            return new Promise((resolve, reject) => {
              assert.deepEqual(state.databaseInfo.tableDetails[databases.generateTableID(id.db, id.table)], { inFlight: true, valid: false });
              response = new protos.cockroach.server.serverpb.TableDetailsResponse(dbTables[databases.generateTableID(req.database, req.table)]);
              resolve(response);
            });
          }

          databasesMocked = proxyquire.load("./databaseInfo", {
            "../util/api": {
              getTableDetails,
            },
          });

          return databasesMocked.refreshTableDetails(id.db, id.table)(dispatch, () => state).then(() => {
            let generatedID = databases.generateTableID(id.db, id.table);
            assert.deepEqual(state.databaseInfo.tableDetails[generatedID].data, new protos.cockroach.server.serverpb.TableDetailsResponse(dbTables[id.db][id.table]));
            assert.deepEqual(state.databaseInfo.tableDetails[generatedID], {
              inFlight: false,
              valid: true,
              data: response,
              lastError: null,
            });
          });
        }));
開發者ID:codepope,項目名稱:cockroach,代碼行數:28,代碼來源:databaseInfo.spec.ts

示例3: it

      it("handles database list errors", function () {
        error = new Error();
        function getDatabaseList(): Promise<DatabasesResponseMessage> {
          return new Promise((resolve, reject) => {
            reject(error);
          });
        }

        databasesMocked = proxyquire.load("./databaseInfo", {
          "../util/api": {
            getDatabaseList,
          },
        });

        return databasesMocked.refreshDatabases()(dispatch, () => state).then(() => {
          assert.deepEqual(state.databaseInfo.databases, { valid: false, inFlight: false, lastError: error });
        });
      });
開發者ID:codepope,項目名稱:cockroach,代碼行數:18,代碼來源:databaseInfo.spec.ts

示例4: before

import {Store} from "@tsed/core";
import {expect} from "chai";
import * as Proxyquire from "proxyquire";
import * as Sinon from "sinon";
import {AcceptMimesMiddleware} from "../../../../src/mvc";

const middleware: any = Sinon.stub();
const useBeforeStub: any = Sinon.stub().returns(middleware);

const {AcceptMime} = Proxyquire.load("../../../../src/mvc/decorators/method/acceptMime", {
  "./useBefore": {UseBefore: useBeforeStub}
});

class Test {
}

describe("AcceptMime", () => {
  before(() => {
    this.descriptor = {};
    this.options = "application/json";
    AcceptMime("application/json")(Test, "test", this.descriptor);
    this.store = Store.from(Test, "test", this.descriptor);
  });

  after(() => {
    delete this.descriptor;
    delete this.options;
  });

  it("should set metadata", () => {
    expect(this.store.get(AcceptMimesMiddleware)).to.deep.eq([this.options]);
開發者ID:Romakita,項目名稱:ts-express-decorators,代碼行數:31,代碼來源:acceptMime.spec.ts

示例5: return

import {Store} from "@tsed/core";
import {assert, expect} from "chai";
import * as Proxyquire from "proxyquire";
import * as Sinon from "sinon";
import {FakeRequest, FakeResponse} from "../../../../../../test/helper";

let middleware: any;
const useAfterStub: any = (_middleware_: any) => {
  middleware = _middleware_;

  return () => {
  };
};

const Header = Proxyquire.load("../../../../src/mvc/decorators/method/header", {
  "./useAfter": {UseAfter: useAfterStub}
}).Header;

class Test {
}

describe("Header", () => {
  describe("when is used as method decorator", () => {
    before(() => {
      this.request = new FakeRequest();
      this.response = new FakeResponse();
      Sinon.stub(this.response, "set").returns(this.response);
      this.nextSpy = Sinon.spy();
    });

    after(() => {
開發者ID:Romakita,項目名稱:ts-express-decorators,代碼行數:31,代碼來源:header.spec.ts

示例6: describe

import {assert} from "chai";
import * as Proxyquire from "proxyquire";
import * as Sinon from "sinon";

const middleware: any = Sinon.stub();
const useStub: any = Sinon.stub().returns(middleware);

const {All, Get, Post, Put, Delete, Head, Patch} = Proxyquire.load("../../../../src/mvc/decorators/method/route", {
  "./use": {Use: useStub}
});

describe("Route decorators", () => {
  describe("All", () => {
    before(() => {
      this.options = ["/", () => {
      }];
      All(...this.options);
    });

    after(() => {
      delete this.descriptor;
      delete this.options;
    });

    it("should create middleware", () => {
      assert(useStub.calledWith("all", ...this.options[0]));
    });
  });

  describe("Get", () => {
    before(() => {
開發者ID:Romakita,項目名稱:ts-express-decorators,代碼行數:31,代碼來源:route.spec.ts

示例7: before

import {Store} from "@tsed/core";
import {expect} from "chai";
import * as Proxyquire from "proxyquire";
import * as Sinon from "sinon";
import {ResponseViewMiddleware} from "../../../../src/mvc";

const middleware: any = Sinon.stub();
const useAfterStub: any = Sinon.stub().returns(middleware);
const {ResponseView} = Proxyquire.load("../../../../src/mvc/decorators/method/responseView", {
  "./useAfter": {UseAfter: useAfterStub}
});

class Test {
}

describe("ResponseView", () => {
  before(() => {
    this.descriptor = {};
    this.options = ["page", {}];
    ResponseView(...this.options)(Test, "test", this.descriptor);
    this.store = Store.from(Test, "test", this.descriptor);
  });

  after(() => {
    delete this.descriptor;
    delete this.options;
  });

  it("should set metadata", () => {
    expect(this.store.get(ResponseViewMiddleware)).to.deep.eq({
      viewPath: this.options[0],
開發者ID:Romakita,項目名稱:ts-express-decorators,代碼行數:31,代碼來源:responseView.spec.ts


注:本文中的proxyquire.load函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。