本文整理汇总了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);
});