How to use the ts-mockito.resetCalls function in ts-mockito

To help you get started, we’ve selected a few ts-mockito examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sillsdev / web-languageforge / src / SIL.XForge.Scripture / ClientApp / src / app / checking / checking-overview / checking-overview.component.spec.ts View on Github external
it('should not add a question if cancelled', fakeAsync(() => {
      const env = new TestEnvironment();
      when(env.mockedQuestionDialogRef.afterClosed()).thenReturn(of('close'));
      env.fixture.detectChanges();
      flush();
      verify(env.mockedTextService.getQuestionData(anything())).twice();

      resetCalls(env.mockedTextService);
      env.clickElement(env.addQuestionButton);
      verify(env.mockedMdcDialog.open(anything(), anything())).once();
      verify(env.mockedTextService.getQuestionData(anything())).never();
      expect().nothing();
    }));
github sillsdev / web-languageforge / src / SIL.XForge.Scripture / ClientApp / src / app / translate / editor / editor.component.spec.ts View on Github external
it('update confidence threshold', fakeAsync(() => {
    const env = new TestEnvironment();
    env.setTranslateConfig({
      selectedTextRef: 'text01',
      selectedChapter: 1,
      selectedSegment: 'verse_1_2',
      confidenceThreshold: 0.5
    });
    env.waitForSuggestion();
    expect(env.component.confidenceThreshold).toBe(50);
    expect(env.component.showSuggestion).toBe(true);
    tick(10000);

    resetCalls(env.mockedSFProjectUserService);
    env.clickSuggestionsMenuButton();
    env.updateConfidenceThresholdSlider(60);
    expect(env.component.confidenceThreshold).toBe(60);
    verify(env.mockedSFProjectUserService.update(anything())).once();
    expect(env.component.showSuggestion).toBe(false);

    resetCalls(env.mockedSFProjectUserService);
    env.updateConfidenceThresholdSlider(40);
    expect(env.component.confidenceThreshold).toBe(40);
    verify(env.mockedSFProjectUserService.update(anything())).once();
    expect(env.component.showSuggestion).toBe(true);

    env.dispose();
  }));
github intershop / intershop-pwa / src / app / core / store / shopping / products / products.effects.spec.ts View on Github external
it('should redirect if triggered', fakeAsync(() => {
      resetCalls(router);

      const action = new fromActions.LoadProductsForCategoryFail({
        categoryId: 'ID',
        error: { status: 404 } as HttpError,
      });

      actions$ = of(action);

      effects.redirectIfErrorInCategoryProducts$.subscribe(noop, fail, noop);

      tick(500);

      expect(location.path()).toEqual('/error');
    }));
  });
github sillsdev / web-languageforge / src / SIL.XForge.Scripture / ClientApp / src / app / translate / editor / editor.component.spec.ts View on Github external
it('local and remote selected segment are different', fakeAsync(() => {
    const env = new TestEnvironment();
    env.setTranslateConfig({ selectedTextRef: 'text01', selectedChapter: 1, selectedSegment: 'verse_1_1' });
    env.waitForSuggestion();
    expect(env.component.chapter).toBe(1);
    expect(env.component.target.segmentRef).toBe('verse_1_1');
    verify(env.mockedRemoteTranslationEngine.translateInteractively(1, anything())).once();

    resetCalls(env.mockedRemoteTranslationEngine);
    env.setTranslateConfig({ selectedTextRef: 'text01', selectedChapter: 1, selectedSegment: 'verse_1_2' });
    env.waitForSuggestion();
    expect(env.component.target.segmentRef).toBe('verse_1_2');
    verify(env.mockedRemoteTranslationEngine.translateInteractively(1, anything())).once();

    env.dispose();
  }));
github intershop / intershop-pwa / src / app / extensions / quoting / store / quoting-store.spec.ts View on Github external
{ type: 'Link', uri: 'customers/CID/users/UID/quoterequests/QRID4' },
            ],
          }).pipe(delay(100))
        );
        when(apiServiceMock.post('customers/CID/users/UID/quoterequests/QRID2/items', anything())).thenReturn(
          of(undefined)
        );
        when(apiServiceMock.post('customers/CID/users/UID/quoterequests/QRID3/items', anything())).thenReturn(
          of(undefined)
        );
        when(apiServiceMock.post('customers/CID/users/UID/quoterequests/QRID4/items', anything())).thenReturn(
          of(undefined)
        );

        store$.reset();
        resetCalls(apiServiceMock);
        setTimeout(() => store$.dispatch(new AddProductToQuoteRequest({ sku: 'SKU', quantity: 1 })), 400);
        setTimeout(() => store$.dispatch(new AddProductToQuoteRequest({ sku: 'SKU', quantity: 1 })), 450);
        setTimeout(() => store$.dispatch(new AddProductToQuoteRequest({ sku: 'SKU', quantity: 1 })), 480);
      });
github sillsdev / web-languageforge / src / SIL.XForge.Scripture / ClientApp / src / app / translate / editor / translate-metrics-session.spec.ts View on Github external
tick(SEND_METRICS_INTERVAL);
    verify(
      env.mockedSFProjectService.addTranslateMetrics(
        'project01',
        deepEqual({
          id: env.session.metrics.id,
          type: 'navigate',
          sessionId: env.session.id,
          textRef: 'text01',
          chapter: 1,
          keyNavigationCount: 2
        })
      )
    ).once();

    resetCalls(env.mockedSFProjectService);
    env.mouseClick();
    expect(env.session.metrics.type).toBe('navigate');
    expect(env.session.metrics.mouseClickCount).toBe(1);
    verify(env.mockedSFProjectService.addTranslateMetrics('project01', anything())).never();

    tick(SEND_METRICS_INTERVAL);
    verify(
      env.mockedSFProjectService.addTranslateMetrics(
        'project01',
        deepEqual({
          id: env.session.metrics.id,
          type: 'navigate',
          sessionId: env.session.id,
          textRef: 'text01',
          chapter: 1,
          keyNavigationCount: 2,