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 9f3e76188..5adc0920a 100644 --- a/src/app/components/current-user/current-user.component.spec.ts +++ b/src/app/components/current-user/current-user.component.spec.ts @@ -23,11 +23,18 @@ * along with Alfresco. If not, see . */ +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 { MaterialModule } from '../../common/material.module'; -import { CoreModule, PeopleContentService } from '@alfresco/adf-core'; +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 + } from '@alfresco/adf-core'; import { CurrentUserComponent } from './current-user.component'; @@ -44,13 +51,23 @@ describe('CurrentUserComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ - MaterialModule, - CoreModule, + HttpClientModule, + TranslateModule.forRoot(), + NoopAnimationsModule, + MatMenuModule, RouterTestingModule ], declarations: [ CurrentUserComponent - ] + ], + providers: [ + { provide: TranslationService, useClass: TranslationMock }, + AlfrescoApiService, + AppConfigService, + StorageService, + PeopleContentService + ], + schemas: [ NO_ERRORS_SCHEMA ] }) .compileComponents() .then(() => { diff --git a/src/app/components/header/header.component.spec.ts b/src/app/components/header/header.component.spec.ts index fb1d51728..09770857c 100644 --- a/src/app/components/header/header.component.spec.ts +++ b/src/app/components/header/header.component.spec.ts @@ -23,15 +23,14 @@ * along with Alfresco. If not, see . */ +import { NO_ERRORS_SCHEMA } from '@angular/core'; import { TestBed } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; -import { CoreModule, AppConfigService, PeopleContentService } from '@alfresco/adf-core'; +import { AppConfigService, PeopleContentService } from '@alfresco/adf-core'; +import { HttpClientModule } from '@angular/common/http'; import { Observable } from 'rxjs/Rx'; -import { CommonModule } from './../../common/common.module'; import { HeaderComponent } from './header.component'; -import { SearchComponent } from '../search/search.component'; -import { CurrentUserComponent } from '../current-user/current-user.component'; describe('HeaderComponent', () => { let fixture; @@ -41,15 +40,17 @@ describe('HeaderComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ imports: [ - CoreModule, - RouterTestingModule, - CommonModule + HttpClientModule, + RouterTestingModule ], declarations: [ - HeaderComponent, - SearchComponent, - CurrentUserComponent - ] + HeaderComponent + ], + providers: [ + AppConfigService, + PeopleContentService + ], + schemas: [ NO_ERRORS_SCHEMA ] }) .overrideProvider(PeopleContentService, { useValue: { @@ -65,16 +66,24 @@ describe('HeaderComponent', () => { if (val === 'application.name') { return 'app-name'; } + + if (val === 'headerColor') { + return 'some-color'; + } + + if (val === 'application.logo') { + return ''; + } }); fixture.detectChanges(); }); - it('should get application name from configuration file', () => { - expect(appConfigService.get).toHaveBeenCalledWith('application.name'); - }); - it('it should set application name', () => { expect(component.appName).toBe('app-name'); }); + + it('it should set header background color', () => { + expect(component.backgroundColor).toBe('some-color'); + }); }); diff --git a/src/app/components/layout/layout.component.spec.ts b/src/app/components/layout/layout.component.spec.ts index 5bd92c25e..37b73bc4d 100644 --- a/src/app/components/layout/layout.component.spec.ts +++ b/src/app/components/layout/layout.component.spec.ts @@ -23,19 +23,22 @@ * along with Alfresco. If not, see . */ +import { NO_ERRORS_SCHEMA } from '@angular/core'; import { RouterTestingModule } from '@angular/router/testing'; import { TestBed, ComponentFixture } from '@angular/core/testing'; import { MinimalNodeEntryEntity } from 'alfresco-js-api'; -import { CoreModule, ContentService, PeopleContentService, AppConfigService } from '@alfresco/adf-core'; +import { TranslateModule } from '@ngx-translate/core'; +import { HttpClientModule } from '@angular/common/http'; +import { + ContentService, PeopleContentService, AppConfigService, + AuthenticationService, UserPreferencesService, TranslationService, + TranslationMock, StorageService, AlfrescoApiService, CookieService, + LogService +} from '@alfresco/adf-core'; import { Observable } from 'rxjs/Observable'; import { BrowsingFilesService } from '../../common/services/browsing-files.service'; import { LayoutComponent } from './layout.component'; -import { CommonModule } from './../../common/common.module'; -import { HeaderComponent } from '../header/header.component'; -import { SidenavComponent } from '../sidenav/sidenav.component'; -import { SearchComponent } from '../search/search.component'; -import { CurrentUserComponent } from '../current-user/current-user.component'; describe('LayoutComponent', () => { let fixture: ComponentFixture; @@ -55,26 +58,32 @@ describe('LayoutComponent', () => { TestBed.configureTestingModule({ imports: [ - CoreModule, - RouterTestingModule, - CommonModule + HttpClientModule, + TranslateModule.forRoot(), + RouterTestingModule ], declarations: [ - LayoutComponent, - HeaderComponent, - SidenavComponent, - SearchComponent, - CurrentUserComponent + LayoutComponent ], providers: [ + { provide: TranslationService, useClass: TranslationMock }, + AlfrescoApiService, + StorageService, + CookieService, + LogService, + UserPreferencesService, + AuthenticationService, + ContentService, AppConfigService, + BrowsingFilesService, { provide: PeopleContentService, useValue: { getCurrentPerson: () => Observable.of({ entry: {} }) } } - ] + ], + schemas: [ NO_ERRORS_SCHEMA ] }); fixture = TestBed.createComponent(LayoutComponent); diff --git a/src/app/components/libraries/libraries.component.spec.ts b/src/app/components/libraries/libraries.component.spec.ts index 706054fbb..c34858680 100644 --- a/src/app/components/libraries/libraries.component.spec.ts +++ b/src/app/components/libraries/libraries.component.spec.ts @@ -120,6 +120,7 @@ describe('Libraries Routed Component', () => { beforeEach(() => { spyOn(alfrescoApi.sitesApi, 'getSites').and.returnValue((Promise.resolve(page))); + spyOn(alfrescoApi.peopleApi, 'getSiteMembership').and.returnValue((Promise.resolve({}))); }); describe('makeLibraryTooltip()', () => { diff --git a/src/app/components/login/login.component.spec.ts b/src/app/components/login/login.component.spec.ts index b0b923c82..b4aee669c 100644 --- a/src/app/components/login/login.component.spec.ts +++ b/src/app/components/login/login.component.spec.ts @@ -23,13 +23,19 @@ * along with Alfresco. If not, see . */ +import { NO_ERRORS_SCHEMA } from '@angular/core'; import { RouterTestingModule } from '@angular/router/testing'; import { Router } from '@angular/router'; +import { HttpClientModule } from '@angular/common/http'; +import { TranslateModule } from '@ngx-translate/core'; import { Location } from '@angular/common'; import { TestBed, async } from '@angular/core/testing'; -import { AuthenticationService, UserPreferencesService } from '@alfresco/adf-core'; +import { + AuthenticationService, UserPreferencesService, TranslationService, + TranslationMock, AppConfigService, StorageService, AlfrescoApiService, + CookieService, LogService +} from '@alfresco/adf-core'; -import { CommonModule } from '../../common/common.module'; import { LoginComponent } from './login.component'; describe('LoginComponent', () => { @@ -43,15 +49,25 @@ describe('LoginComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ - RouterTestingModule, - CommonModule + HttpClientModule, + TranslateModule.forRoot(), + RouterTestingModule ], declarations: [ LoginComponent ], providers: [ - Location - ] + { provide: TranslationService, useClass: TranslationMock }, + Location, + CookieService, + LogService, + StorageService, + AlfrescoApiService, + AppConfigService, + AuthenticationService, + UserPreferencesService + ], + schemas: [ NO_ERRORS_SCHEMA ] }); fixture = TestBed.createComponent(LoginComponent); diff --git a/src/app/components/search/search.component.spec.ts b/src/app/components/search/search.component.spec.ts index 7cc3dc903..de37de5b5 100644 --- a/src/app/components/search/search.component.spec.ts +++ b/src/app/components/search/search.component.spec.ts @@ -23,13 +23,12 @@ * along with Alfresco. If not, see . */ +import { NO_ERRORS_SCHEMA } from '@angular/core'; import { TestBed, async } from '@angular/core/testing'; -import { CoreModule } from '@alfresco/adf-core'; import { Router } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; import { SearchComponent } from './search.component'; -import { CommonModule } from './../../common/common.module'; describe('SearchComponent', () => { let fixture; @@ -39,13 +38,12 @@ describe('SearchComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ - CoreModule, - RouterTestingModule, - CommonModule + RouterTestingModule ], declarations: [ SearchComponent - ] + ], + schemas: [ NO_ERRORS_SCHEMA ] }) .compileComponents() .then(() => { diff --git a/src/app/components/sidenav/sidenav.component.spec.ts b/src/app/components/sidenav/sidenav.component.spec.ts index 9d2ed7dcb..db3440f88 100644 --- a/src/app/components/sidenav/sidenav.component.spec.ts +++ b/src/app/components/sidenav/sidenav.component.spec.ts @@ -26,8 +26,14 @@ import { NO_ERRORS_SCHEMA } from '@angular/core'; import { TestBed, async } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; - -import { CoreModule, ContentService, AppConfigService } from '@alfresco/adf-core'; +import { TranslateModule } from '@ngx-translate/core'; +import { MatMenuModule } from '@angular/material'; +import { HttpClientModule } from '@angular/common/http'; +import { + ContentService, AppConfigService, AuthenticationService, + UserPreferencesService, StorageService, AlfrescoApiService, + CookieService, LogService +} from '@alfresco/adf-core'; import { BrowsingFilesService } from '../../common/services/browsing-files.service'; import { SidenavComponent } from './sidenav.component'; @@ -50,13 +56,23 @@ describe('SidenavComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ - RouterTestingModule, - CoreModule + HttpClientModule, + MatMenuModule, + TranslateModule.forRoot(), + RouterTestingModule ], declarations: [ SidenavComponent ], providers: [ + LogService, + CookieService, + AlfrescoApiService, + StorageService, + UserPreferencesService, + AuthenticationService, + ContentService, + AppConfigService, BrowsingFilesService ], schemas: [ NO_ERRORS_SCHEMA ]