diff --git a/src/app/components/current-user/current-user.component.html b/src/app/components/current-user/current-user.component.html index 638f9230b..9ce4be5ac 100644 --- a/src/app/components/current-user/current-user.component.html +++ b/src/app/components/current-user/current-user.component.html @@ -9,7 +9,7 @@ - diff --git a/src/app/components/current-user/current-user.component.spec.ts b/src/app/components/current-user/current-user.component.spec.ts index 77d6a8ddf..88f025232 100644 --- a/src/app/components/current-user/current-user.component.spec.ts +++ b/src/app/components/current-user/current-user.component.spec.ts @@ -25,18 +25,19 @@ import { NO_ERRORS_SCHEMA } from '@angular/core'; import { TestBed, async } from '@angular/core/testing'; -import { RouterTestingModule } from '@angular/router/testing'; import { Observable } from 'rxjs/Rx'; -import { HttpClientModule } from '@angular/common/http'; -import { TranslateModule } from '@ngx-translate/core'; -import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { MatMenuModule } from '@angular/material'; import { - TranslationService, TranslationMock, AlfrescoApiService, - AppConfigService, StorageService, PeopleContentService, UserPreferencesService + AlfrescoApiService, + AppConfigService, + StorageService, + PeopleContentService, + UserPreferencesService, + AppConfigPipe } from '@alfresco/adf-core'; import { CurrentUserComponent } from './current-user.component'; +import { AppTestingModule } from '../../testing/app-testing.module'; describe('CurrentUserComponent', () => { let fixture; @@ -51,17 +52,14 @@ describe('CurrentUserComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ - HttpClientModule, - TranslateModule.forRoot(), - NoopAnimationsModule, - MatMenuModule, - RouterTestingModule + AppTestingModule, + MatMenuModule ], declarations: [ - CurrentUserComponent + CurrentUserComponent, + AppConfigPipe ], providers: [ - { provide: TranslationService, useClass: TranslationMock }, AlfrescoApiService, AppConfigService, StorageService, diff --git a/src/app/components/current-user/current-user.component.ts b/src/app/components/current-user/current-user.component.ts index 6ef40663a..b91bd6ce1 100644 --- a/src/app/components/current-user/current-user.component.ts +++ b/src/app/components/current-user/current-user.component.ts @@ -24,7 +24,7 @@ */ import { Component, OnInit, OnDestroy } from '@angular/core'; -import { PeopleContentService, AppConfigService } from '@alfresco/adf-core'; +import { PeopleContentService } from '@alfresco/adf-core'; import { Subscription } from 'rxjs/Rx'; @Component({ @@ -38,8 +38,7 @@ export class CurrentUserComponent implements OnInit, OnDestroy { user: any = null; constructor( - private peopleApi: PeopleContentService, - private appConfig: AppConfigService + private peopleApi: PeopleContentService ) {} ngOnInit() { @@ -71,8 +70,4 @@ export class CurrentUserComponent implements OnInit, OnDestroy { const { userFirstName: first, userLastName: last } = this; return [ first[0], last[0] ].join(''); } - - get showLanguagePicker() { - return this.appConfig.get('languagePicker') || false; - } } diff --git a/src/app/components/favorites/favorites.component.spec.ts b/src/app/components/favorites/favorites.component.spec.ts index 806666799..c6529cf93 100644 --- a/src/app/components/favorites/favorites.component.spec.ts +++ b/src/app/components/favorites/favorites.component.spec.ts @@ -26,11 +26,8 @@ import { Observable } from 'rxjs/Rx'; import { NO_ERRORS_SCHEMA } from '@angular/core'; import { Router } from '@angular/router'; -import { RouterTestingModule } from '@angular/router/testing'; -import { HttpClientModule } from '@angular/common/http'; import { TestBed, async, ComponentFixture } from '@angular/core/testing'; import { - NotificationService, TranslationService, TranslationMock, NodesApiService, AlfrescoApiService, ContentService, UserPreferencesService, LogService, AppConfigService, StorageService, CookieService, ThumbnailService, @@ -39,17 +36,13 @@ import { } from '@alfresco/adf-core'; import { DocumentListComponent, CustomResourcesService } from '@alfresco/adf-content-services'; -import { TranslateModule } from '@ngx-translate/core'; -import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { MatMenuModule, MatSnackBarModule, MatIconModule } from '@angular/material'; import { DocumentListService } from '@alfresco/adf-content-services'; import { ContentManagementService } from '../../common/services/content-management.service'; import { NodePermissionService } from '../../common/services/node-permission.service'; import { FavoritesComponent } from './favorites.component'; -import { StoreModule } from '@ngrx/store'; -import { appReducer } from '../../store/reducers/app.reducer'; -import { INITIAL_STATE } from '../../store/states/app.state'; +import { AppTestingModule } from '../../testing/app-testing.module'; describe('FavoritesComponent', () => { let fixture: ComponentFixture; @@ -90,13 +83,9 @@ describe('FavoritesComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ + AppTestingModule, MatMenuModule, - NoopAnimationsModule, - HttpClientModule, - TranslateModule.forRoot(), - RouterTestingModule, MatSnackBarModule, MatIconModule, - StoreModule.forRoot({ app: appReducer }, { initialState: INITIAL_STATE }) ], declarations: [ DataTableComponent, @@ -108,14 +97,12 @@ describe('FavoritesComponent', () => { AppConfigPipe ], providers: [ - { provide: TranslationService, useClass: TranslationMock }, AuthenticationService, UserPreferencesService, AppConfigService, StorageService, CookieService, AlfrescoApiService, CustomResourcesService, LogService, - NotificationService, ContentManagementService, ContentService, NodesApiService, diff --git a/src/app/testing/app-testing.module.ts b/src/app/testing/app-testing.module.ts new file mode 100644 index 000000000..e061a03de --- /dev/null +++ b/src/app/testing/app-testing.module.ts @@ -0,0 +1,57 @@ +/*! + * @license + * Alfresco Example Content Application + * + * Copyright (C) 2005 - 2018 Alfresco Software Limited + * + * This file is part of the Alfresco Example Content Application. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * The Alfresco Example Content Application is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Alfresco Example Content Application is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ + +import { NgModule } from '@angular/core'; +import { TranslatePipe, TranslateService } from '@ngx-translate/core'; +import { TranslatePipeMock } from './translate-pipe.directive'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { TranslationService, TranslationMock } from '@alfresco/adf-core'; +import { HttpClientModule } from '@angular/common/http'; +import { TranslateServiceMock } from './translation.service'; +import { StoreModule } from '@ngrx/store'; +import { appReducer } from '../store/reducers/app.reducer'; +import { INITIAL_STATE } from '../store/states/app.state'; +import { RouterTestingModule } from '@angular/router/testing'; + +@NgModule({ + imports: [ + NoopAnimationsModule, + HttpClientModule, + RouterTestingModule, + StoreModule.forRoot({ app: appReducer }, { initialState: INITIAL_STATE }) + ], + declarations: [ + TranslatePipeMock + ], + exports: [ + TranslatePipeMock + ], + providers: [ + { provide: TranslationService, useClass: TranslationMock }, + { provide: TranslateService, useClass: TranslateServiceMock }, + { provide: TranslatePipe, useClass: TranslatePipeMock } + ] +}) +export class AppTestingModule {} diff --git a/src/app/testing/translate-pipe.directive.ts b/src/app/testing/translate-pipe.directive.ts new file mode 100644 index 000000000..727f85e8b --- /dev/null +++ b/src/app/testing/translate-pipe.directive.ts @@ -0,0 +1,33 @@ +/*! + * @license + * Alfresco Example Content Application + * + * Copyright (C) 2005 - 2018 Alfresco Software Limited + * + * This file is part of the Alfresco Example Content Application. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * The Alfresco Example Content Application is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Alfresco Example Content Application is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ + +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ name: 'translate' }) +export class TranslatePipeMock implements PipeTransform { + transform(value: any, ...args: any[]) { + return value; + } +} diff --git a/src/app/testing/translation.service.ts b/src/app/testing/translation.service.ts new file mode 100644 index 000000000..09dbd495b --- /dev/null +++ b/src/app/testing/translation.service.ts @@ -0,0 +1,34 @@ +/*! + * @license + * Alfresco Example Content Application + * + * Copyright (C) 2005 - 2018 Alfresco Software Limited + * + * This file is part of the Alfresco Example Content Application. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * The Alfresco Example Content Application is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Alfresco Example Content Application is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ + +import { Injectable } from '@angular/core'; +import { TranslateService } from '@ngx-translate/core'; + +@Injectable() +export class TranslateServiceMock extends TranslateService { + constructor() { + super(null, null, null, null, null); + } +}