本文整理匯總了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();
}