mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
unit test performance (#3194)
* DataTable (-4 sec) * PaginationComponent (-1 sec) * DocumentList * custom testbed setup, test upgrades * test fixes * more test fixes * remove fdescribe * test fixes * test fixes * more test fixes * test fixes * upgrade tests * update tests * upgrade tests * upgrade tests * upgrade tests * upgrade tests * update tests * translate loader fixes * auth and cookie fixes * upgrade tests * upgrade tests * test fixes * almost there * diable broken tests * process tests (part 1) * fix lint issues * another test upgrade * almost there * cleanup * insights testing upgrade * improve tests * tests cleanup * tests cleanup * cleanup tests * test cleanup * favorite nodes tests * rebase fix syntax * fix core test * give up test focus * flush tabs * fix search test * Update document-list.component.spec.ts * fix document list lock * increase tick time * remove duplicate test
This commit is contained in:
committed by
Eugenio Romano
parent
9fbfcfa96e
commit
382ea3c1b3
@@ -15,14 +15,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { Pagination } from 'alfresco-js-api';
|
||||
import { MaterialModule } from '../material.module';
|
||||
import { InfinitePaginationComponent } from './infinite-pagination.component';
|
||||
import { PaginatedComponent } from './paginated-component.interface';
|
||||
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
|
||||
import { setupTestBed } from '../testing/setupTestBed';
|
||||
import { CoreTestingModule } from '../testing/core.testing.module';
|
||||
|
||||
describe('InfinitePaginationComponent', () => {
|
||||
|
||||
@@ -30,17 +30,9 @@ describe('InfinitePaginationComponent', () => {
|
||||
let component: InfinitePaginationComponent;
|
||||
let pagination: Pagination;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
NoopAnimationsModule,
|
||||
MaterialModule
|
||||
],
|
||||
declarations: [
|
||||
InfinitePaginationComponent
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
setupTestBed({
|
||||
imports: [CoreTestingModule]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(InfinitePaginationComponent);
|
||||
@@ -54,7 +46,6 @@ describe('InfinitePaginationComponent', () => {
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
TestBed.resetTestingModule();
|
||||
});
|
||||
|
||||
describe('Standalone', () => {
|
||||
|
@@ -15,17 +15,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { Pagination } from 'alfresco-js-api';
|
||||
import { MaterialModule } from '../material.module';
|
||||
import { TranslateLoaderService } from '../services/translate-loader.service';
|
||||
import { TranslationService } from '../services/translation.service';
|
||||
import { PaginationComponent } from './pagination.component';
|
||||
import { PaginatedComponent } from './public-api';
|
||||
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
|
||||
import { setupTestBed } from '../testing/setupTestBed';
|
||||
import { CoreTestingModule } from '../testing/core.testing.module';
|
||||
|
||||
class FakePaginationInput implements Pagination {
|
||||
count: number = 25;
|
||||
@@ -45,47 +42,19 @@ describe('PaginationComponent', () => {
|
||||
let fixture: ComponentFixture<PaginationComponent>;
|
||||
let component: PaginationComponent;
|
||||
|
||||
let changePageNumberSpy: jasmine.Spy;
|
||||
let changePageSizeSpy: jasmine.Spy;
|
||||
let nextPageSpy: jasmine.Spy;
|
||||
let prevPageSpy: jasmine.Spy;
|
||||
setupTestBed({
|
||||
imports: [CoreTestingModule],
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
});
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
HttpClientModule,
|
||||
MaterialModule,
|
||||
TranslateModule.forRoot({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useClass: TranslateLoaderService
|
||||
}
|
||||
})
|
||||
],
|
||||
declarations: [
|
||||
PaginationComponent
|
||||
],
|
||||
providers: [
|
||||
TranslationService
|
||||
],
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
}).compileComponents()
|
||||
.then(() => {
|
||||
fixture = TestBed.createComponent(PaginationComponent);
|
||||
component = fixture.componentInstance;
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(PaginationComponent);
|
||||
component = fixture.componentInstance;
|
||||
});
|
||||
|
||||
(<any> component).ngAfterViewInit = jasmine
|
||||
.createSpy('ngAfterViewInit').and
|
||||
.callThrough();
|
||||
|
||||
changePageNumberSpy = spyOn(component.changePageNumber, 'emit');
|
||||
changePageSizeSpy = spyOn(component.changePageSize, 'emit');
|
||||
nextPageSpy = spyOn(component.nextPage, 'emit');
|
||||
prevPageSpy = spyOn(component.prevPage, 'emit');
|
||||
|
||||
fixture.detectChanges();
|
||||
});
|
||||
}));
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
it('should have an "empty" class if no items present', () => {
|
||||
fixture.detectChanges();
|
||||
@@ -165,6 +134,7 @@ describe('PaginationComponent', () => {
|
||||
});
|
||||
|
||||
it('goes next', () => {
|
||||
const nextPageSpy = spyOn(component.nextPage, 'emit');
|
||||
expect(component.current).toBe(3);
|
||||
component.goNext();
|
||||
|
||||
@@ -175,6 +145,7 @@ describe('PaginationComponent', () => {
|
||||
});
|
||||
|
||||
it('goes previous', () => {
|
||||
const prevPageSpy = spyOn(component.prevPage, 'emit');
|
||||
expect(component.current).toBe(3);
|
||||
component.goPrevious();
|
||||
|
||||
@@ -185,6 +156,7 @@ describe('PaginationComponent', () => {
|
||||
});
|
||||
|
||||
it('changes page size', () => {
|
||||
const changePageSizeSpy = spyOn(component.changePageSize, 'emit');
|
||||
expect(component.current).toBe(3);
|
||||
component.onChangePageSize(50);
|
||||
|
||||
@@ -195,6 +167,7 @@ describe('PaginationComponent', () => {
|
||||
});
|
||||
|
||||
it('changes page number', () => {
|
||||
const changePageNumberSpy = spyOn(component.changePageNumber, 'emit');
|
||||
expect(component.current).toBe(3);
|
||||
component.onChangePageNumber(5);
|
||||
|
||||
|
Reference in New Issue
Block a user