当前位置: 首页>>代码示例>>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;未经允许,请勿转载。