當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。