本文整理匯總了TypeScript中Sinon.assert.alwaysCalledOn方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript assert.alwaysCalledOn方法的具體用法?TypeScript assert.alwaysCalledOn怎麽用?TypeScript assert.alwaysCalledOn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Sinon.assert
的用法示例。
在下文中一共展示了assert.alwaysCalledOn方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('predicates are called with the same context and proper arguments', function () {
const exampleContext = {some: 'context'},
structure = {
key0: sinon.stub().returns(true),
key1: sinon.stub().returns(true)
},
exampleObject = {
key0: 1,
key1: 'string'
};
const extraArgs = [2, 3];
const args = [exampleObject, ...extraArgs];
isValidStructure.call(exampleContext, structure, ...args);
isValidStructure(structure).call(exampleContext, ...args);
sinon.assert.calledTwice(structure.key0);
sinon.assert.calledTwice(structure.key1);
sinon.assert.alwaysCalledOn(structure.key0, exampleContext);
sinon.assert.alwaysCalledOn(structure.key1, exampleContext);
sinon.assert.calledWith(structure.key0, 1, ...extraArgs);
sinon.assert.calledWith(structure.key1, 'string', ...extraArgs);
});
示例2: it
it('calls the predicate in the same context and forward value arguments', function () {
const exampleContext = {example: 'context'};
const stub = sinon.stub().returns(true);
const args = [1, '2', null];
undefinedOr(stub).call(exampleContext, ...args);
undefinedOr.call(exampleContext, stub, ...args);
sinon.assert.calledTwice(stub);
sinon.assert.alwaysCalledOn(stub, exampleContext);
sinon.assert.alwaysCalledWith(stub, ...args);
});
示例3: 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);
});
示例4: it
it("should execute callback with given context as this", () => {
const executeSpy = sinon.spy(),
commandContext = commonHelpers.createNote();
const command = new commands.Command({
canExecute: () => true,
execute: executeSpy,
context: commandContext
});
command.execute();
sinon.assert.calledOnce(executeSpy);
sinon.assert.alwaysCalledOn(executeSpy, commandContext);
});