当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript assert.callCount方法代码示例

本文整理汇总了TypeScript中Sinon.assert.callCount方法的典型用法代码示例。如果您正苦于以下问题:TypeScript assert.callCount方法的具体用法?TypeScript assert.callCount怎么用?TypeScript assert.callCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sinon.assert的用法示例。


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

示例1: test

  test('Creates a single Esqueue worker for Reporting, even if there are multiple export types', async () => {
    const createWorker = createWorkerFactory(
      getMockServer([
        { executeJobFactory: executeJobFactoryStub },
        { executeJobFactory: executeJobFactoryStub },
        { executeJobFactory: executeJobFactoryStub },
        { executeJobFactory: executeJobFactoryStub },
        { executeJobFactory: executeJobFactoryStub },
      ])
    );
    const registerWorkerSpy = sinon.spy(queue, 'registerWorker');

    createWorker(queue);

    sinon.assert.callCount(executeJobFactoryStub, 5);
    sinon.assert.callCount(registerWorkerSpy, 1);

    const { firstCall } = registerWorkerSpy;
    const [workerName, workerFn, workerOpts] = firstCall.args;

    expect(workerName).toBe('reporting');
    expect(workerFn).toMatchInlineSnapshot(`[Function]`);
    expect(workerOpts).toMatchInlineSnapshot(`
Object {
  "interval": 3300,
  "intervalErrorMultiplier": 10,
  "kibanaId": "g9ymiujthvy6v8yrh7567g6fwzgzftzfr",
  "kibanaName": "test-server-123",
}
`);
  });
开发者ID:elastic,项目名称:kibana,代码行数:31,代码来源:create_worker.test.ts

示例2: done

 sniffer.on('end', () => {
   sinon.assert.callCount(spy, 3);
   sinon.assert.calledWithMatch(spy, 'lorem-ipsum.txt.gz', match1);
   sinon.assert.calledWithMatch(spy, 'lorem-ipsum.txt.gz', match2);
   sinon.assert.calledWithMatch(spy, 'lorem-ipsum.txt.gz', match3);
   done();
 });
开发者ID:nspragg,项目名称:filesniffer,代码行数:7,代码来源:filesniffer.ts

示例3:

                    .then(() => {
                        sinon.assert.callCount(spy, limit);

                        for (let i = 0, len = limit; i < len; i++) {
                            dfds[i].reject(err);
                        }

                        return dfds[limit - 1].promise.catch(common.noop);
                    })
开发者ID:spatools,项目名称:promizr,代码行数:9,代码来源:queue.ts

示例4: it

    it("sends a single ping event instead of reporting stats if a user has opted out", async function() {
      postStub.resolves({ status: 200 });
      store.setOptOut(true);
      await store.reportStats(getDate);
      await store.reportStats(getDate);
      sinon.assert.calledWith(postStub, pingEvent);

      // event should only be sent the first time even though we call report stats
      sinon.assert.callCount(postStub, 1);
    });
开发者ID:drvegass,项目名称:telemetry,代码行数:10,代码来源:index.spec.ts

示例5: it

    it('calls a predicate with the same context and proper arguments', function () {
        const exampleContext = {some: 'property'};
        const stub = sinon.stub().returns(true);

        const arr = [1, 2];
        const extraArgs = ['super', 'extra', 'args'];
        isArrayOf(stub).call(exampleContext, arr, ...extraArgs);
        isArrayOf.call(exampleContext, stub, arr, ...extraArgs);

        sinon.assert.callCount(stub, 4);
        sinon.assert.alwaysCalledOn(stub, exampleContext);
        sinon.assert.calledWith(stub, 1, ...extraArgs);
        sinon.assert.calledWith(stub, 2, ...extraArgs);
    });
开发者ID:wookieb,项目名称:predicates,代码行数:14,代码来源:arrayOfTest.ts

示例6: it

        it("check main flow", () => {
            const cookieParser = {Cookie: "payload"};
            const expressSession = {Session: "payload"};

            const stubCookie = Sinon.stub().returns(cookieParser);
            const stubSession = Sinon.stub().returns(expressSession);

            const AppProxy = Proxyquire("../app", {
                "cookie-parser": stubCookie,
                "express-session": stubSession,
            });

            const application = new AppProxy.Application();
            const app = Express();
            const config = {
                session: {
                    secret: "Session Secret",
                },
            };
            const stubConfig = Sinon.stub(AppProxy, "config").get(() => config);
            const stubAppUse = Sinon.stub(app, "use");

            application.initSessionManagement(app);
            stubConfig.restore();
            stubAppUse.restore();

            Sinon.assert.callOrder(
                stubCookie,
                stubAppUse,
                stubSession,
                stubAppUse,
            );
            Sinon.assert.calledWithExactly(stubCookie);
            Sinon.assert.calledWithExactly(stubSession, {
                resave: true,
                saveUninitialized: false,
                secret: config.session.secret,
            });

            Sinon.assert.callCount(stubAppUse, 2);
            stubAppUse.args[0][0].should.be.deep.equal(cookieParser);
            stubAppUse.args[1][0].should.be.deep.equals(expressSession);
        });
开发者ID:YuriyGorvitovskiy,项目名称:Taskenize,代码行数:43,代码来源:app.ts

示例7: test

test('finbot > rejects a token which is too short', (t) => {
  const token = '0123456789012345678';

  const robot = new MockRobot();
  const respondStub = sinon.stub(robot, 'respond');

  const response = new MockResponse();
  const replyStub = sinon.stub(response, 'reply');

  response.match = [null, token];

  respondStub.callsArgWith(1, response);

  const secureBrain = new MockSecureBrain();
  const brainSetSpy = sinon.spy(secureBrain, 'set');

  SettingScript(robot, secureBrain);

  sinon.assert.calledWith(respondStub, /set token (.+)/i, sinon.match.func);
  sinon.assert.calledWith(replyStub, 'Token looks to be too short');

  sinon.assert.callCount(brainSetSpy, 0);
});
开发者ID:Codesleuth,项目名称:hubot-appveyor,代码行数:23,代码来源:settings.test.ts


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