How to use the ts-mockito/lib/ts-mockito.verify 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 / xforge-common / system-administration / sa-user-entry.component.spec.ts View on Github external
it('should allow the user to be updated when password field is untouched', fakeAsync(() => {
      const env = new TestUserEntryComponent();
      env.useExistingUser();
      expect(env.component.showPasswordPanel).toBe(false);
      // The user's password is not stored on the form
      expect(env.component.password.value).toBe('');
      expect(env.component.password.hasError('required')).toBe(true);
      // The validations on the password get bypassed when showPasswordPanel is false
      env.clickElement(env.updateButton);
      verify(env.mockedUserService.onlineUpdateAttributes(anything(), anything())).once();
    }));
github ivarvh / movielistr-backend-ts-ioc / test / services / DirectorService.spec.ts View on Github external
it("should call the delete on the repository", async () => {
            when(directorRepository.deleteDirectorWithId(testId)).thenReturn(Promise.resolve());
            await serviceUnderTest.delete(testId);
            verify(directorRepository.deleteDirectorWithId(testId)).called();
        });
github sillsdev / web-languageforge / src / SIL.XForge.Scripture / ClientApp / src / xforge-common / system-administration / sa-user-entry.component.spec.ts View on Github external
it('should report conflicts', fakeAsync(() => {
      const env = new TestUserEntryComponent();
      when(env.mockedUserService.onlineCreate(anything())).thenThrow(new MockClientError(409, 'Duplicate Email!'));
      env.simulateAddUser();
      env.setInputValue(env.nameInput, 'New Name');
      env.setInputValue(env.emailInput, env.testUser.email);
      env.setInputValue(env.passwordInput, env.testUser.password);
      expect(env.component.accountUserForm.valid).toBe(true);
      env.clickElement(env.addButton);
      verify(env.mockedUserService.onlineCreate(anything())).once();
      verify(env.mockedNoticeService.show('User account could not be created due to a conflict.')).once();
    }));
github sillsdev / web-languageforge / src / SIL.XForge.Scripture / ClientApp / src / xforge-common / system-administration / sa-user-entry.component.spec.ts View on Github external
it('should not submit if form is invalid ', fakeAsync(() => {
      const env = new TestUserEntryComponent();
      env.simulateAddUser();
      env.setInputValue(env.nameInput, '');
      expect(env.component.fullName.hasError('required')).toBe(true);
      env.setInputValue(env.emailInput, 'invalidemail');
      expect(env.component.email.hasError('email')).toBe(true);
      env.setInputValue(env.emailInput, 'invalidemail@example');
      expect(env.component.email.hasError('pattern')).toBe(true);
      env.setInputValue(env.passwordInput, '');
      expect(env.component.password.hasError('required')).toBe(true);
      env.clickElement(env.addButton);
      verify(env.mockedUserService.onlineCreate(anything())).never();
      verify(env.mockedNoticeService.show(anything())).never();
    }));
github sillsdev / web-languageforge / src / SIL.XForge.Scripture / ClientApp / src / xforge-common / system-administration / sa-user-entry.component.spec.ts View on Github external
it('should not submit if form is invalid', fakeAsync(() => {
      const env = new TestUserEntryComponent();
      env.useExistingUser();
      env.setInputValue(env.nameInput, '');
      expect(env.component.fullName.hasError('required')).toBe(true);
      env.setInputValue(env.emailInput, '');
      expect(env.component.email.hasError('required')).toBe(true);
      env.setInputValue(env.emailInput, 'notvalidemail');
      expect(env.component.email.hasError('email')).toBe(true);
      env.clickElement(env.updateButton);
      verify(env.mockedUserService.onlineUpdateAttributes(anything(), anything())).never();
    }));
github sillsdev / web-languageforge / src / SIL.XForge.Scripture / ClientApp / src / xforge-common / system-administration / sa-user-entry.component.spec.ts View on Github external
it('should report conflicts', fakeAsync(() => {
      const env = new TestUserEntryComponent();
      when(env.mockedUserService.onlineUpdateAttributes(anything(), anything())).thenThrow(
        new MockClientError(409, 'Duplicate Email!')
      );
      env.useExistingUser();
      env.setInputValue(env.nameInput, 'Something New');
      env.clickElement(env.updateButton);
      verify(env.mockedUserService.onlineUpdateAttributes(anything(), anything())).once();
      verify(env.mockedNoticeService.show('User account could not be updated due to a conflict.')).once();
      expect().nothing();
    }));
github intershop / intershop-pwa / src / app / shared / services / suggest / search-box.service.api.spec.ts View on Github external
it('should call api service on receiving search term', inject([SearchBoxApiService], (searchBoxApiService: SearchBoxApiService) => {
    searchBoxApiService.searchEntries('url');
    verify(apiServiceMock.get(anything())).once();
  }));
});
github intershop / intershop-pwa / src / app / components / category-navigation / subcategory-navigation / subcategory-navigation.component.spec.ts View on Github external
it('should call CategoriesService.getCategory if subcategories data is not loaded', () => {
    component.category.subCategories = null;
    component.category.hasOnlineSubCategories = true;
    fixture.detectChanges();
    verify(categoriesServiceMock.getCategory(anything())).once();
  });
});
github intershop / intershop-pwa / src / app / core / services / api.service.translate.spec.ts View on Github external
it('should not perform link translation when not requested', () => {
    apiService.get('categories').subscribe(data => {
      expect(data).toEqual(categoriesResponse);
    });
    verify(httpClient.get(categoriesPath, new Object(anything()))).once();
    verify(httpClient.get(webcamsPath, new Object(anything()))).never();
  });
github intershop / intershop-pwa / src / app / core / services / api.service.translate.spec.ts View on Github external
}
    });

    TestBed.configureTestingModule({
      providers: [
        { provide: HttpClient, useFactory: () => instance(httpClient) },
        { provide: REST_ENDPOINT, useValue: `${BASE_URL}/site` },
        { provide: ICM_SERVER_URL, useValue: BASE_URL },
        { provide: Store, useFactory: () => instance(storeMock$) },
        ApiServiceErrorHandler,
        ApiService,
      ],
    });
    apiService = TestBed.get(ApiService);

    verify(httpClient.get(categoriesPath, new Object(anything()))).never();
    verify(httpClient.get(webcamsPath, new Object(anything()))).never();
  });