How to use the ts-mockito/lib/ts-mockito.anything 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
useExistingUser(): void {
    when(this.mockedUserService.onlineGet(anything())).thenReturn(of(new MapQueryResults(this.testUser)));
    // set the editUserId to display the details of the test user
    this.component.editUserId = 'user01';
    this.fixture.detectChanges();
    tick();
  }
github intershop / intershop-pwa / src / app / services / mock-api-service.spec.ts View on Github external
it('should return data returened by http', () => {
        const suggestionData = new ArrayBuffer(3);
        when(httpClient.get(anything(), anything())).thenReturn(Observable.of(suggestionData));
        let suggestionResults;
        mockApiService.get('suggest?SearchTerm=', null, null).subscribe((data) => {
            suggestionResults = suggestionData;
        });
        expect(suggestionResults).toBe(suggestionData);
    });
});
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 intershop / intershop-pwa / src / app / components / category-navigation / subcategory-navigation / subcategory-navigation.component.spec.ts View on Github external
}).compileComponents().then(() => {
      fixture = TestBed.createComponent(SubCategoryNavigationComponent);
      component = fixture.componentInstance;
      category.hasOnlineSubCategories = true;
      category.subCategories = categories;
      component.category = category;
      component.currentCategoryUri = 'Computers/06';
      component.category.uri = '/categories/Computers/06';
      when(categoriesServiceMock.getCategory(anything())).thenReturn(Observable.of(category));
    });
  }));
github intershop / intershop-pwa / src / app / services / mock-api-service.spec.ts View on Github external
beforeEach(() => {
        httpClient = mock(HttpClient);
        customErrorHandler = mock(CustomErrorHandler);
        cacheCustomService = mock(CacheCustomService);
        const configSettings = {
            exlcudePath: ['categories12'],
            includePath: ['categories/computers12'],
            mockAllRequest: true
        };

        when(cacheCustomService.cacheKeyExists(anything())).thenReturn(true);
        when(cacheCustomService.getCachedData(anything())).thenReturn(configSettings);

        mockApiService = new MockApiService(instance(httpClient), instance(customErrorHandler), instance(cacheCustomService));
    });
github intershop / intershop-pwa / src / app / services / routes-parser-locale-currency / localize-router.parser.spec.ts View on Github external
describe('LocalizeParser', () => {
  let injector: Injector;
  let loader: ManualParserLoader;
  let translate: TranslateService;
  let location: Location;
  let settings: LocalizeRouterSettings;

  let routes: Routes;
  let locales: any;
  let langs: string[];
  const prefix = 'PREFIX.';
  const translateServiceMock: any = mock(TranslateService);
  const locationMock: any = mock(Location);
  when(locationMock.path(anything())).thenReturn('');
  translateServiceMock.content = {
    'PREFIX.home': 'home_',
    'PREFIX.about': 'about_',
    'PREFIX.contact': 'contact_',
    'PREFIX.info': 'info_'
  };
  when(translateServiceMock.setDefaultLang(anyString())).thenReturn();
  when(translateServiceMock.getDefaultLang()).thenReturn('En');
  when(translateServiceMock.use(anyString())).thenCall((lang: string) => {
    return Observable.of(Object.keys(translateServiceMock.content).reduce((prev: any, key) => {
      prev[key] = translateServiceMock.content[key] + lang;
      return prev;
    }, {}));
  });
  when(translateServiceMock.get(anyString())).thenCall((input: string) => {
    return Observable.of(translateServiceMock.content[input] ? translateServiceMock.content[input] + 'en' : input);