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/>. * 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 { TestBed, async } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing'; import { RouterTestingModule } from '@angular/router/testing';
import { Observable } from 'rxjs/Rx'; import { Observable } from 'rxjs/Rx';
import { MaterialModule } from '../../common/material.module'; import { HttpClientModule } from '@angular/common/http';
import { CoreModule, PeopleContentService } from '@alfresco/adf-core'; 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'; import { CurrentUserComponent } from './current-user.component';
@@ -44,13 +51,23 @@ describe('CurrentUserComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [
MaterialModule, HttpClientModule,
CoreModule, TranslateModule.forRoot(),
NoopAnimationsModule,
MatMenuModule,
RouterTestingModule RouterTestingModule
], ],
declarations: [ declarations: [
CurrentUserComponent CurrentUserComponent
] ],
providers: [
{ provide: TranslationService, useClass: TranslationMock },
AlfrescoApiService,
AppConfigService,
StorageService,
PeopleContentService
],
schemas: [ NO_ERRORS_SCHEMA ]
}) })
.compileComponents() .compileComponents()
.then(() => { .then(() => {

View File

@@ -23,15 +23,14 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * 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 { TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/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 { Observable } from 'rxjs/Rx';
import { CommonModule } from './../../common/common.module';
import { HeaderComponent } from './header.component'; import { HeaderComponent } from './header.component';
import { SearchComponent } from '../search/search.component';
import { CurrentUserComponent } from '../current-user/current-user.component';
describe('HeaderComponent', () => { describe('HeaderComponent', () => {
let fixture; let fixture;
@@ -41,15 +40,17 @@ describe('HeaderComponent', () => {
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [
CoreModule, HttpClientModule,
RouterTestingModule, RouterTestingModule
CommonModule
], ],
declarations: [ declarations: [
HeaderComponent, HeaderComponent
SearchComponent, ],
CurrentUserComponent providers: [
] AppConfigService,
PeopleContentService
],
schemas: [ NO_ERRORS_SCHEMA ]
}) })
.overrideProvider(PeopleContentService, { .overrideProvider(PeopleContentService, {
useValue: { useValue: {
@@ -65,16 +66,24 @@ describe('HeaderComponent', () => {
if (val === 'application.name') { if (val === 'application.name') {
return 'app-name'; return 'app-name';
} }
if (val === 'headerColor') {
return 'some-color';
}
if (val === 'application.logo') {
return '';
}
}); });
fixture.detectChanges(); fixture.detectChanges();
}); });
it('should get application name from configuration file', () => {
expect(appConfigService.get).toHaveBeenCalledWith('application.name');
});
it('it should set application name', () => { it('it should set application name', () => {
expect(component.appName).toBe('app-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/>. * 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 { RouterTestingModule } from '@angular/router/testing';
import { TestBed, ComponentFixture } from '@angular/core/testing'; import { TestBed, ComponentFixture } from '@angular/core/testing';
import { MinimalNodeEntryEntity } from 'alfresco-js-api'; 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 { Observable } from 'rxjs/Observable';
import { BrowsingFilesService } from '../../common/services/browsing-files.service'; import { BrowsingFilesService } from '../../common/services/browsing-files.service';
import { LayoutComponent } from './layout.component'; 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', () => { describe('LayoutComponent', () => {
let fixture: ComponentFixture<LayoutComponent>; let fixture: ComponentFixture<LayoutComponent>;
@@ -55,26 +58,32 @@ describe('LayoutComponent', () => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [
CoreModule, HttpClientModule,
RouterTestingModule, TranslateModule.forRoot(),
CommonModule RouterTestingModule
], ],
declarations: [ declarations: [
LayoutComponent, LayoutComponent
HeaderComponent,
SidenavComponent,
SearchComponent,
CurrentUserComponent
], ],
providers: [ providers: [
{ provide: TranslationService, useClass: TranslationMock },
AlfrescoApiService,
StorageService,
CookieService,
LogService,
UserPreferencesService,
AuthenticationService,
ContentService,
AppConfigService, AppConfigService,
BrowsingFilesService,
{ {
provide: PeopleContentService, provide: PeopleContentService,
useValue: { useValue: {
getCurrentPerson: () => Observable.of({ entry: {} }) getCurrentPerson: () => Observable.of({ entry: {} })
} }
} }
] ],
schemas: [ NO_ERRORS_SCHEMA ]
}); });
fixture = TestBed.createComponent(LayoutComponent); fixture = TestBed.createComponent(LayoutComponent);

View File

@@ -120,6 +120,7 @@ describe('Libraries Routed Component', () => {
beforeEach(() => { beforeEach(() => {
spyOn(alfrescoApi.sitesApi, 'getSites').and.returnValue((Promise.resolve(page))); spyOn(alfrescoApi.sitesApi, 'getSites').and.returnValue((Promise.resolve(page)));
spyOn(alfrescoApi.peopleApi, 'getSiteMembership').and.returnValue((Promise.resolve({})));
}); });
describe('makeLibraryTooltip()', () => { describe('makeLibraryTooltip()', () => {

View File

@@ -23,13 +23,19 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * 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 { RouterTestingModule } from '@angular/router/testing';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { HttpClientModule } from '@angular/common/http';
import { TranslateModule } from '@ngx-translate/core';
import { Location } from '@angular/common'; import { Location } from '@angular/common';
import { TestBed, async } from '@angular/core/testing'; 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'; import { LoginComponent } from './login.component';
describe('LoginComponent', () => { describe('LoginComponent', () => {
@@ -43,15 +49,25 @@ describe('LoginComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [
RouterTestingModule, HttpClientModule,
CommonModule TranslateModule.forRoot(),
RouterTestingModule
], ],
declarations: [ declarations: [
LoginComponent LoginComponent
], ],
providers: [ providers: [
Location { provide: TranslationService, useClass: TranslationMock },
] Location,
CookieService,
LogService,
StorageService,
AlfrescoApiService,
AppConfigService,
AuthenticationService,
UserPreferencesService
],
schemas: [ NO_ERRORS_SCHEMA ]
}); });
fixture = TestBed.createComponent(LoginComponent); fixture = TestBed.createComponent(LoginComponent);

View File

@@ -23,13 +23,12 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * 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 { TestBed, async } from '@angular/core/testing';
import { CoreModule } from '@alfresco/adf-core';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing'; import { RouterTestingModule } from '@angular/router/testing';
import { SearchComponent } from './search.component'; import { SearchComponent } from './search.component';
import { CommonModule } from './../../common/common.module';
describe('SearchComponent', () => { describe('SearchComponent', () => {
let fixture; let fixture;
@@ -39,13 +38,12 @@ describe('SearchComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [
CoreModule, RouterTestingModule
RouterTestingModule,
CommonModule
], ],
declarations: [ declarations: [
SearchComponent SearchComponent
] ],
schemas: [ NO_ERRORS_SCHEMA ]
}) })
.compileComponents() .compileComponents()
.then(() => { .then(() => {

View File

@@ -26,8 +26,14 @@
import { NO_ERRORS_SCHEMA } from '@angular/core'; import { NO_ERRORS_SCHEMA } from '@angular/core';
import { TestBed, async } from '@angular/core/testing'; import { TestBed, async } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing'; import { RouterTestingModule } from '@angular/router/testing';
import { TranslateModule } from '@ngx-translate/core';
import { CoreModule, ContentService, AppConfigService } from '@alfresco/adf-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 { BrowsingFilesService } from '../../common/services/browsing-files.service';
import { SidenavComponent } from './sidenav.component'; import { SidenavComponent } from './sidenav.component';
@@ -50,13 +56,23 @@ describe('SidenavComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [
RouterTestingModule, HttpClientModule,
CoreModule MatMenuModule,
TranslateModule.forRoot(),
RouterTestingModule
], ],
declarations: [ declarations: [
SidenavComponent SidenavComponent
], ],
providers: [ providers: [
LogService,
CookieService,
AlfrescoApiService,
StorageService,
UserPreferencesService,
AuthenticationService,
ContentService,
AppConfigService,
BrowsingFilesService BrowsingFilesService
], ],
schemas: [ NO_ERRORS_SCHEMA ] schemas: [ NO_ERRORS_SCHEMA ]