How to use the ts-mockito/lib/ts-mockito.anyString 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 intershop / intershop-pwa / src / app / services / routes-parser-locale-currency / localize-router.parser.spec.ts View on Github external
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);
  });
  when(translateServiceMock.getBrowserLang()).thenReturn('En');

  // tslint:disable-next-line:prefer-mocks-instead-of-stubs-in-tests
  class ManualParserLoader extends LocalizeParser {
    constructor(translateService: TranslateService,
      locationService: Location,
      localizeRouterSettings: LocalizeRouterSettings,
      languages: string[],
github intershop / intershop-pwa / src / app / services / routes-parser-locale-currency / localize-router.parser.spec.ts View on Github external
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);
  });
  when(translateServiceMock.getBrowserLang()).thenReturn('En');

  // tslint:disable-next-line:prefer-mocks-instead-of-stubs-in-tests
  class ManualParserLoader extends LocalizeParser {
    constructor(translateService: TranslateService,
      locationService: Location,
      localizeRouterSettings: LocalizeRouterSettings,
      languages: string[],
      localesCollection: any,
      prefixes: string = 'ROUTES.',
      pattern: string = '{LANG}/{CURRENCY}') {
      super(translateService, locationService, localizeRouterSettings);
      this.langs = languages;
      this.localesCollection = localesCollection;
github intershop / intershop-pwa / src / app / services / routes-parser-locale-currency / localize-router.parser.spec.ts View on Github external
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);
  });
  when(translateServiceMock.getBrowserLang()).thenReturn('En');

  // tslint:disable-next-line:prefer-mocks-instead-of-stubs-in-tests
  class ManualParserLoader extends LocalizeParser {
    constructor(translateService: TranslateService,
      locationService: Location,
github intershop / intershop-pwa / src / app / core / services / api.service.translate.spec.ts View on Github external
beforeEach(() => {
    httpClient = mock(HttpClient);
    storeMock$ = mock(Store);
    when(storeMock$.pipe(anything())).thenReturn(EMPTY);

    when(httpClient.get(anyString(), new Object(anything()))).thenCall((path: string, obj) => {
      if (path === categoriesPath) {
        return deepCopyObservable(categoriesResponse);
      } else if (path === webcamsPath) {
        return deepCopyObservable(webcamResponse);
      } else {
        return of(`path '${path}' does not exist`);
      }
    });

    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,