Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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[],
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;
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,
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,