• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript simple-mock.mock函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中simple-mock.mock函数的典型用法代码示例。如果您正苦于以下问题:TypeScript mock函数的具体用法?TypeScript mock怎么用?TypeScript mock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了mock函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: it

    it("will reject expired incoming messages", function (done) {

      const confirmMethod = simple.mock(AMQPSubscriberAdapter.prototype,
        "confirmProcessedMessage");

      const rejectMethod = simple.mock(AMQPSubscriberAdapter.prototype,
        "rejectMessage");

      const onMessageMethod = simple.mock();

      consumer.on("message", onMessageMethod);

      const expiredMessage = merge({}, fixtures.consumer_basic, {
        meta: {ttl: 10000},
      });

      publisher.publish([
        fixtures.consumer_basic,
        expiredMessage,
        fixtures.consumer_basic,
      ], function (err) {
        if (err) return done(err);

        setTimeout(function () {
          expect(onMessageMethod.callCount).equals(2);
          expect(onMessageMethod.calls[0].arg).deep.equals(fixtures.consumer_basic);
          expect(onMessageMethod.calls[1].arg).deep.equals(fixtures.consumer_basic);
          expect(rejectMethod.callCount).equals(1);
          expect(confirmMethod.callCount).equals(2);
          expect(rejectMethod.lastCall.k).above(confirmMethod.calls[0].k);
          expect(rejectMethod.lastCall.k).below(confirmMethod.calls[1].k);
          done();
        }, 100);
      });
    });
开发者ID:tcdl,项目名称:msb,代码行数:35,代码来源:amqp.ts


示例2: applyBuildMocks

function applyBuildMocks(buildQueue : Array<any>) {
    builds_mock.queue = buildQueue;
    simple.mock(builds, 'getNextQueued').callFn(builds_mock.getNextQueued);
    simple.mock(builds, 'markAsStarted').callFn(builds_mock.markAsStarted);
    simple.mock(builds, 'markAsSuccess').callFn(builds_mock.markAsSuccess);
    simple.mock(builds, 'markAsFailed').callFn(builds_mock.markAsFailed);
}
开发者ID:mserranom,项目名称:lean-ci-agent,代码行数:7,代码来源:index_test.ts


示例3: it

    it("can wait for acks without any determined number of responses", function(done) {
      producer.publish.callbackWith();

      const endHandler = simple.mock();

      const obj = new Requester({
        waitForResponses: 0,
        waitForAcksMs: 800,
      });

      simple.mock(obj, "listenForResponses").returnWith();
      simple.mock(obj, "isAwaitingAcks").returnWith(true);
      simple.mock(messageFactory, "createRequestMessage").returnWith({
        topics: {to: "my:topic", response: "my:topic:response"},
      });

      obj
      .on("end", endHandler)
      .publish({});

      expect((obj.listenForResponses as any).called).to.equal(true);
      expect((obj.listenForResponses as any).lastCall.args[0]).to.equal("my:topic:response");
      expect(producer.publish.called).to.equal(true);
      expect(endHandler.called).to.equal(false);

      done();
    });
开发者ID:tcdl,项目名称:msb,代码行数:27,代码来源:requester.ts


示例4: it

  it("should set serviceDetails dynamically", function (done) {
    const fakeInterfaces = {
      en0: [{
        address: "1.2.3.4",
        netmask: "255.255.255.0",
        family: "IPv4",
        mac: "60:03:08:92:27:88",
        internal: false,
      }],
    };
    simple.mock(require("os"), "networkInterfaces").returnWith(fakeInterfaces);
    simple.mock(require("os"), "hostname").returnWith("abchost");

    serviceDetails = require(serviceDetailsModulePath);

    expect(serviceDetails.hostname).equals("abchost");
    expect(serviceDetails.ip).equals("1.2.3.4");
    expect(serviceDetails.pid).equals(process.pid);

    expect(serviceDetails.name).to.be.a("string");
    expect(!!serviceDetails.version.match(/\d+\.\d+\.\d+/)).to.be.true;
    expect(serviceDetails.instanceId).length(24);

    done();
  });
开发者ID:tcdl,项目名称:msb,代码行数:25,代码来源:serviceDetails.ts


示例5: beforeEach

 beforeEach(function (done) {
   simple.restore();
   simple.mock(connection, "publish");
   simple.mock(connection, "exchange");
   simple.mock(exchange, "declare");
   simple.mock(publisher, "publishMessageStr");
   done();
 });
开发者ID:tcdl,项目名称:msb,代码行数:8,代码来源:publisher.ts



注:本文中的simple-mock.mock函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript simple-mock.restore函数代码示例发布时间:2022-05-25
下一篇:
TypeScript simple-dom.HTMLSerializer类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap