当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript assert.calledOn方法代码示例

本文整理汇总了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());
    });
开发者ID:gristlabs,项目名称:grainjs,代码行数:42,代码来源:obsArray.ts

示例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();
}
开发者ID:gristlabs,项目名称:grainjs,代码行数:6,代码来源:testutil2.ts


注:本文中的Sinon.assert.calledOn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。