當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。