本文整理汇总了TypeScript中Sinon.assert.calledOn方法的典型用法代码示例。如果您正苦于以下问题:TypeScript assert.calledOn方法的具体用法?TypeScript assert.calledOn怎么用?TypeScript assert.calledOn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sinon.assert
的用法示例。
在下文中一共展示了assert.calledOn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should dispose items it owns', function() {
const arr = obsArray<Foo>();
const initial = [Foo.create(arr, 10), Foo.create(arr, 20), Foo.create(arr, 30)];
arr.push(...initial);
// Just to check what's in the array to start with.
assert.lengthOf(arr.get(), 3);
assert.deepEqual(arr.get(), initial);
assert.notStrictEqual(arr.get(), initial);
assertResetFirstArgs(fooConstruct, 10, 20, 30);
sinon.assert.notCalled(fooDispose);
// Delete two elements: they should get disposed, but the remaining one should not.
const x = arr.splice(0, 2);
assert.lengthOf(arr.get(), 1);
assert.deepEqual(arr.get(), [initial[2]]);
assert.lengthOf(x, 2);
sinon.assert.calledOn(fooDispose.getCall(0), initial[0]);
sinon.assert.calledOn(fooDispose.getCall(1), initial[1]);
assertResetFirstArgs(fooDispose, 10, 20);
assert.isTrue(initial[0].isDisposed());
assert.isTrue(initial[1].isDisposed());
assert.isFalse(initial[2].isDisposed());
// Reassign: the remaining element should now also get disposed.
let objects: Foo[];
arr.set(objects = [Foo.create(arr, 40), Foo.create(arr, 50)]);
assert.lengthOf(arr.get(), 2);
assert.deepEqual(arr.get(), objects);
assertResetFirstArgs(fooConstruct, 40, 50);
assertResetSingleCall(fooDispose, initial[2], 30);
assert.isTrue(initial[2].isDisposed());
assert.isFalse(objects[0].isDisposed());
assert.isFalse(objects[1].isDisposed());
// Dispose the entire array: previously assigned elements should be disposed.
arr.dispose();
sinon.assert.notCalled(fooConstruct);
assertResetFirstArgs(fooDispose, 40, 50);
assert.isTrue(objects[0].isDisposed());
assert.isTrue(objects[1].isDisposed());
});
示例2: assertResetSingleCall
export function assertResetSingleCall(spy: sinon.SinonSpy, context: any, ...args: any[]): void {
sinon.assert.calledOnce(spy);
sinon.assert.calledOn(spy, context);
sinon.assert.calledWithExactly(spy, ...args);
spy.resetHistory();
}