granular dependencies (#200)

This commit is contained in:
Cilibiu Bogdan
2018-02-24 09:52:10 +02:00
committed by Denys Vuika
parent 4d7b6d3271
commit 9bbc11b0b0
7 changed files with 117 additions and 51 deletions

View File

@@ -23,11 +23,18 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
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(() => {

View File

@@ -23,15 +23,14 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
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');
});
});

View File

@@ -23,19 +23,22 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
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<LayoutComponent>;
@@ -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);

View File

@@ -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()', () => {

View File

@@ -23,13 +23,19 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
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);

View File

@@ -23,13 +23,12 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
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(() => {

View File

@@ -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 ]