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


TypeScript assert.notCalled方法代码示例

本文整理汇总了TypeScript中Sinon.assert.notCalled方法的典型用法代码示例。如果您正苦于以下问题:TypeScript assert.notCalled方法的具体用法?TypeScript assert.notCalled怎么用?TypeScript assert.notCalled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sinon.assert的用法示例。


在下文中一共展示了assert.notCalled方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: test

test("Broadcast message with enabled should work correctly", (t) => {
  const testNode3 = rootNode.children[0];
  const testNode2 = testNode3.children[0];

  resetSpies();
  sinon.assert.notCalled(testComponent3Spy);
  sinon.assert.notCalled(testComponent2Spy);
  sinon.assert.notCalled(testComponentOptionalSpy);
  sinon.assert.notCalled(testComponent1Spy);

  resetSpies();
  rootNode.broadcastMessage("onTest");
  sinon.assert.notCalled(testComponent3Spy);
  sinon.assert.notCalled(testComponent2Spy);
  sinon.assert.notCalled(testComponentOptionalSpy);
  sinon.assert.notCalled(testComponent1Spy);

  resetSpies();
  testNode3.enabled = true;
  testNode2.enabled = false;
  rootNode.broadcastMessage("onTest");
  sinon.assert.called(testComponent3Spy);
  sinon.assert.notCalled(testComponent2Spy);
  sinon.assert.notCalled(testComponentOptionalSpy);
  sinon.assert.called(testComponent1Spy);

  resetSpies();
  testNode2.enabled = true;
  rootNode.broadcastMessage("onTest");
  sinon.assert.called(testComponent3Spy);
  sinon.assert.called(testComponent2Spy);
  sinon.assert.called(testComponentOptionalSpy);
  sinon.assert.called(testComponent1Spy);
});
开发者ID:emadurandal,项目名称:GrimoireJS,代码行数:34,代码来源:GomlNode2Test.ts

示例2: it

  it('should allow setting unowned values', function() {
    // If we don't use autoDispose and don't use the observable as a IDisposableOwner, then it
    // doesn't take ownership of its values.
    let f: Foo;
    let g: Foo;
    const obs = obsHolder<Foo>(f = Foo.create(null));
    assertResetSingleCall(fooConstruct, f);
    assert.strictEqual(obs.get(), f);
    assert.isFalse(f.isDisposed());

    obs.set(g = Foo.create(null, "x"));
    assertResetSingleCall(fooConstruct, g, "x");
    assert.strictEqual(obs.get(), g);

    assertResetSingleCall(fooDispose, f);
    assert.isTrue(f.isDisposed());
    assert.isFalse(g.isDisposed());

    obs.set(f = Foo.create(null));
    assert.strictEqual(obs.get(), f);
    sinon.assert.notCalled(fooDispose);
    assert.isFalse(f.isDisposed());
    assert.isFalse(g.isDisposed());

    obs.dispose();
    sinon.assert.notCalled(fooDispose);
    assert.isFalse(f.isDisposed());
    assert.isFalse(g.isDisposed());
  });
开发者ID:gristlabs,项目名称:grainjs,代码行数:29,代码来源:obsHolder.ts

示例3: it

    it("should not call onSuccess nor onError after abortSegment call", () => {
        const loader = mock<LoaderInterface>(LoaderInterfaceEmptyImpl);

        const onSuccess = sinon.spy();
        let segmentLoadedListener: Function = () => { throw new Error("SegmentLoaded listener not set"); };
        when(loader.on(Events.SegmentLoaded, anyFunction())).thenCall((eventName_unused, listener) => {
            segmentLoadedListener = listener;
        });

        const onError = sinon.spy();

        const segment = new Segment(
            "id",
            testPlaylist.baseUrl + "segment-1045.ts",
            testPlaylist.url,
            testPlaylist.url,
            undefined,
            "1045",
            undefined, 0, new ArrayBuffer(0));

        const manager = new SegmentManager(instance(loader));
        manager.processPlaylist(testPlaylist.url, testPlaylist.content, testPlaylist.url);
        manager.loadSegment(segment.url, undefined, onSuccess, onError);
        manager.abortSegment(segment.url, undefined);
        segmentLoadedListener(segment);

        sinon.assert.notCalled(onSuccess);
        sinon.assert.notCalled(onError);
    });
开发者ID:AlexKar2019,项目名称:p2p-media-loader,代码行数:29,代码来源:segment-manager.test.ts

示例4: it

  it('should dispose owned values', function() {
    const obs = observable("a");
    const comp = computed<Foo>((use) => Foo.create(use.owner, use(obs)));

    let f = comp.get();
    assert.isOk(f);
    assertResetSingleCall(fooConstruct, f, "a");
    sinon.assert.notCalled(fooDispose);

    obs.set("b");     // This should trigger a re-evaluation of comp.
    const g = comp.get();
    assertResetSingleCall(fooConstruct, g, "b");
    assertResetSingleCall(fooDispose, f);
    assert.isTrue(f.isDisposed());
    assert.isFalse(g.isDisposed());

    obs.set("b");     // This should not trigger anything.
    sinon.assert.notCalled(fooConstruct);
    sinon.assert.notCalled(fooDispose);
    assert.strictEqual(comp.get(), g);

    obs.set("x");     // Triggers another reevaluation.
    f = comp.get();
    assert.isOk(f);
    assertResetSingleCall(fooConstruct, f, "x");
    assertResetSingleCall(fooDispose, g);
    assert.isFalse(f.isDisposed());
    assert.isTrue(g.isDisposed());

    comp.dispose();
    sinon.assert.notCalled(fooConstruct);
    assertResetSingleCall(fooDispose, f);
    assert.isTrue(f.isDisposed());
    assert.isTrue(g.isDisposed());
  });
开发者ID:gristlabs,项目名称:grainjs,代码行数:35,代码来源:computedHolder.ts

示例5: it

    it("can remove all events", () => {
        removeAllDelegatedEvents();
        (document.querySelector(".scope1 .filterSelector") as HTMLElement).click();

        sinon.assert.notCalled(callback1);
        sinon.assert.notCalled(callback2);
    });
开发者ID:vanilla,项目名称:vanilla,代码行数:7,代码来源:domUtils.test.ts

示例6: it

    it("should dispose previously held object", function() {
      const holder = Holder.create<Foo>(null);
      assert.isTrue(holder.isEmpty());
      assert.strictEqual(holder.get(), null);

      const foo = Foo.create(holder, 17, noop);
      assert.isFalse(holder.isEmpty());
      sinon.assert.notCalled(fooDisposed);
      assert.strictEqual(holder.get(), foo);

      const bar = Foo.create(holder, 28, noop);
      assert.isFalse(holder.isEmpty());
      assertResetSingleCall(fooDisposed, foo);
      assert.strictEqual(holder.get(), bar);
      assert.strictEqual(holder.get()!.a, 28);

      holder.clear();
      assert.isTrue(holder.isEmpty());
      assertResetSingleCall(fooDisposed, bar);
      assert.strictEqual(holder.get(), null);

      const baz = Foo.create(holder, 39, noop);
      assert.isFalse(holder.isEmpty());
      sinon.assert.notCalled(fooDisposed);
      assert.strictEqual(holder.get(), baz);

      holder.dispose();
      assertResetSingleCall(fooDisposed, baz);
    });
开发者ID:gristlabs,项目名称:grainjs,代码行数:29,代码来源:dispose2.ts

示例7: it

    it('does not extend session if authentication fails.', async () => {
      const systemAPIRequest = requestFixture({ headers: { xCustomHeader: 'xxx' } });
      const notSystemAPIRequest = requestFixture({ headers: { xCustomHeader: 'yyy' } });

      session.get.withArgs(systemAPIRequest).resolves({
        state: { authorization: 'Basic xxx' },
        provider: 'basic',
      });

      session.get.withArgs(notSystemAPIRequest).resolves({
        state: { authorization: 'Basic yyy' },
        provider: 'basic',
      });

      server.plugins.kibana.systemApi.isSystemApiRequest
        .withArgs(systemAPIRequest)
        .returns(true)
        .withArgs(notSystemAPIRequest)
        .returns(false);

      cluster.callWithRequest
        .withArgs(systemAPIRequest)
        .rejects(new Error('some error'))
        .withArgs(notSystemAPIRequest)
        .rejects(new Error('some error'));

      const systemAPIAuthenticationResult = await authenticate(systemAPIRequest);
      expect(systemAPIAuthenticationResult.failed()).toBe(true);

      const notSystemAPIAuthenticationResult = await authenticate(notSystemAPIRequest);
      expect(notSystemAPIAuthenticationResult.failed()).toBe(true);

      sinon.assert.notCalled(session.clear);
      sinon.assert.notCalled(session.set);
    });
开发者ID:,项目名称:,代码行数:35,代码来源:

示例8: it

    it("should dispose computed disposable items", function() {
      const valArr = obsArray(["1", "2", "3"]);
      const mapped = computedArray(valArr, (val, i, arr) => Foo.create(arr, val));
      assertResetFirstArgs(fooConstruct, "1", "2", "3");
      sinon.assert.notCalled(fooDispose);

      valArr.splice(1, 0, "4", "5");
      assert.deepEqual(valArr.get(), ["1", "4", "5", "2", "3"]);
      assert.lengthOf(mapped.get(), 5);
      assertResetFirstArgs(fooConstruct, "4", "5");
      sinon.assert.notCalled(fooDispose);

      valArr.splice(0, 2);
      assert.deepEqual(valArr.get(), ["5", "2", "3"]);
      assert.lengthOf(mapped.get(), 3);
      sinon.assert.notCalled(fooConstruct);
      assertResetFirstArgs(fooDispose, "1", "4");

      valArr.set(["a", "b", "c"]);
      assertResetFirstArgs(fooConstruct, "a", "b", "c");
      // Note that order of disposal is not guaranteed; here happens to be the order of creation.
      assertResetFirstArgs(fooDispose, "2", "3", "5");

      mapped.dispose();
      sinon.assert.notCalled(fooConstruct);
      assertResetFirstArgs(fooDispose, "a", "b", "c");
    });
开发者ID:gristlabs,项目名称:grainjs,代码行数:27,代码来源:obsArray.ts

示例9: it

  it("should not create unnecessary subscriptions", function() {
    const kObs: IKnockoutObservable<string> = ko.observable("a");
    const gObs = fromKo(kObs);

    // Ensure there is no subscription if it's not needed yet.
    assert.equal(kObs.getSubscriptionsCount(), 0);
    assert.equal(gObs.get(), "a");
    kObs("b");
    assert.equal(gObs.get(), "b");
    assert.equal(kObs.getSubscriptionsCount(), 0);

    // Add a subscription, check that it works.
    const spy = sinon.spy((a: any) => a);
    const lis = gObs.addListener(spy);
    assert.equal(kObs.getSubscriptionsCount(), 1);
    kObs("c");
    assert.equal(gObs.get(), "c");
    assertResetSingleCall(spy, undefined, "c", "b");

    // Add another subscription to fromKo(kObs) in the form of a computed, using use(kObs).
    const spyComp = sinon.spy((a: any) => a);
    const gComp = computed((use) => spyComp(use(kObs) + use(kObs)));
    assertResetSingleCall(spyComp, undefined, "cc");
    assert.equal(gComp.get(), "cc");
    sinon.assert.notCalled(spyComp);

    // Check that both subscriptions notice changes.
    kObs("d");
    assertResetSingleCall(spy, undefined, "d", "c");
    assertResetSingleCall(spyComp, undefined, "dd");
    assert.equal(gObs.get(), "d");
    assert.equal(gComp.get(), "dd");

    // There should be only one wrapper, so still only one subscription to kObs itself.
    assert.equal(kObs.getSubscriptionsCount(), 1);

    // Dispose one (second remains).
    lis.dispose();
    assert.equal(kObs.getSubscriptionsCount(), 1);

    // Check computed still reacts to changes.
    kObs("e");
    assertResetSingleCall(spyComp, undefined, "ee");
    assert.equal(gObs.get(), "e");
    assert.equal(gComp.get(), "ee");
    sinon.assert.notCalled(spy);

    // Dispose the other subscription, ensure kObs is now unused.
    gComp.dispose();
    assert.equal(kObs.getSubscriptionsCount(), 0);

    // We should still be able get its value via gObs though.
    kObs("f");
    assert.equal(gObs.get(), "f");
    assert.equal(gComp.get(), null);
    sinon.assert.notCalled(spy);
    sinon.assert.notCalled(spyComp);
  });
开发者ID:gristlabs,项目名称:grainjs,代码行数:58,代码来源:kowrap.ts


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