本文整理匯總了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",
}
`);
});
示例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();
});
示例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);
})
示例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);
});
示例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);
});
示例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);
});
示例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);
});