unit test cleanup (#454)

* auth mock

* avoid using jasmine

* cleanup preview tests

* cleanup recent files tests

* cleanup shared files tests

* remove fdescribe

* update tests

* move adf services to single place

* move app specific services to single place

* cleanup directive tests

* cleanup directive tests

* update directive tests
This commit is contained in:
Denys Vuika
2018-06-24 17:33:50 +01:00
committed by GitHub
parent e846d97317
commit ac6e96530f
19 changed files with 223 additions and 543 deletions

View File

@@ -23,34 +23,21 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { TestBed, async, ComponentFixture } from '@angular/core/testing';
import { TestBed, ComponentFixture } from '@angular/core/testing';
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 {
NotificationService, TranslationService, TranslationMock,
NodesApiService, AlfrescoApiService, ContentService,
UserPreferencesService, LogService, AppConfigService,
StorageService, CookieService, ThumbnailService, AuthenticationService,
NodesApiService, AlfrescoApiService,
TimeAgoPipe, NodeNameTooltipPipe, NodeFavoriteDirective, DataTableComponent, AppConfigPipe
} 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 { DocumentListComponent } from '@alfresco/adf-content-services';
import { ShareDataTableAdapter } from '@alfresco/adf-content-services';
import { LibrariesComponent } from './libraries.component';
import { StoreModule } from '@ngrx/store';
import { appReducer } from '../../store/reducers/app.reducer';
import { INITIAL_STATE } from '../../store/states/app.state';
import { ContentManagementService } from '../../common/services/content-management.service';
import { ExperimentalDirective } from '../../directives/experimental.directive';
import { AppTestingModule } from '../../testing/app-testing.module';
describe('Libraries Routed Component', () => {
describe('LibrariesComponent', () => {
let fixture: ComponentFixture<LibrariesComponent>;
let component: LibrariesComponent;
let nodesApi: NodesApiService;
@@ -75,17 +62,9 @@ describe('Libraries Routed Component', () => {
};
});
beforeEach(async(() => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
MatMenuModule,
NoopAnimationsModule,
HttpClientModule,
TranslateModule.forRoot(),
RouterTestingModule,
MatSnackBarModule, MatIconModule,
StoreModule.forRoot({ app: appReducer }, { initialState: INITIAL_STATE })
],
imports: [ AppTestingModule ],
declarations: [
DataTableComponent,
TimeAgoPipe,
@@ -96,36 +75,17 @@ describe('Libraries Routed Component', () => {
AppConfigPipe,
ExperimentalDirective
],
providers: [
{ provide: TranslationService, useClass: TranslationMock },
AuthenticationService,
UserPreferencesService,
AppConfigService, StorageService, CookieService,
AlfrescoApiService,
LogService,
NotificationService,
ContentService,
NodesApiService,
DocumentListService,
ThumbnailService,
CustomResourcesService,
ContentManagementService
],
schemas: [ NO_ERRORS_SCHEMA ]
})
.compileComponents().then(() => {
fixture = TestBed.createComponent(LibrariesComponent);
component = fixture.componentInstance;
nodesApi = TestBed.get(NodesApiService);
alfrescoApi = TestBed.get(AlfrescoApiService);
alfrescoApi.reset();
router = TestBed.get(Router);
});
}));
beforeEach(() => {
fixture = TestBed.createComponent(LibrariesComponent);
component = fixture.componentInstance;
nodesApi = TestBed.get(NodesApiService);
alfrescoApi = TestBed.get(AlfrescoApiService);
alfrescoApi.reset();
router = TestBed.get(Router);
spyOn(alfrescoApi.sitesApi, 'getSites').and.returnValue((Promise.resolve(page)));
spyOn(alfrescoApi.peopleApi, 'getSiteMembership').and.returnValue((Promise.resolve({})));
});