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,74 +15,45 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { async, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture } from '@angular/core/testing';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
|
||||
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
import { NodesApiService, TranslationService } from '@alfresco/adf-core';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { async, ComponentFixture } from '@angular/core/testing';
|
||||
import { MatDialogRef } from '@angular/material';
|
||||
import { NodesApiService, setupTestBed } from '@alfresco/adf-core';
|
||||
import { FolderDialogComponent } from './folder.dialog';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||
import { By } from '@angular/platform-browser';
|
||||
|
||||
describe('FolderDialogComponent', () => {
|
||||
|
||||
let fixture: ComponentFixture<FolderDialogComponent>;
|
||||
let component: FolderDialogComponent;
|
||||
let translationService: TranslationService;
|
||||
let nodesApi: NodesApiService;
|
||||
let dialogRef;
|
||||
let dialogRef = {
|
||||
close: jasmine.createSpy('close')
|
||||
};
|
||||
|
||||
setupTestBed({
|
||||
imports: [ContentTestingModule],
|
||||
providers: [
|
||||
{ provide: MatDialogRef, useValue: dialogRef }
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
dialogRef.close.calls.reset();
|
||||
fixture = TestBed.createComponent(FolderDialogComponent);
|
||||
component = fixture.componentInstance;
|
||||
nodesApi = TestBed.get(NodesApiService);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
TestBed.resetTestingModule();
|
||||
});
|
||||
|
||||
describe('Material dialog behaviour', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
dialogRef = { close: jasmine.createSpy('close') };
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
BrowserDynamicTestingModule
|
||||
],
|
||||
declarations: [
|
||||
FolderDialogComponent
|
||||
],
|
||||
providers: [
|
||||
{ provide: MatDialogRef, useValue: dialogRef },
|
||||
{ provide: MAT_DIALOG_DATA, useValue: {
|
||||
editTitle: 'edit',
|
||||
createTitle: 'create'
|
||||
} }
|
||||
]
|
||||
});
|
||||
|
||||
// entryComponents are not supported yet on TestBed, that is why this ugly workaround:
|
||||
// https://github.com/angular/angular/issues/10760
|
||||
TestBed.overrideModule(BrowserDynamicTestingModule, {
|
||||
set: { entryComponents: [FolderDialogComponent] }
|
||||
});
|
||||
|
||||
TestBed.compileComponents();
|
||||
}));
|
||||
describe('Edit', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(FolderDialogComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
||||
nodesApi = TestBed.get(NodesApiService);
|
||||
|
||||
translationService = TestBed.get(TranslationService);
|
||||
spyOn(translationService, 'get').and.returnValue(Observable.of('message'));
|
||||
});
|
||||
|
||||
it('should have the proper overridden title in case of editing', () => {
|
||||
|
||||
component.data = {
|
||||
folder: {
|
||||
id: 'node-id',
|
||||
@@ -92,134 +63,61 @@ describe('FolderDialogComponent', () => {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
const title = fixture.debugElement.query(By.css('[mat-dialog-title]'));
|
||||
expect(title === null).toBe(false);
|
||||
expect(title.nativeElement.innerText.trim()).toBe('edit');
|
||||
});
|
||||
|
||||
it('should have the proper overridden title in case of creating', () => {
|
||||
|
||||
component.data = {
|
||||
parentNodeId: 'parentNodeId',
|
||||
folder: null
|
||||
};
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
const title = fixture.debugElement.query(By.css('[mat-dialog-title]'));
|
||||
expect(title === null).toBe(false);
|
||||
expect(title.nativeElement.innerText.trim()).toBe('create');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Basic component behaviour', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
dialogRef = { close: jasmine.createSpy('close') };
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
BrowserDynamicTestingModule
|
||||
],
|
||||
declarations: [
|
||||
FolderDialogComponent
|
||||
],
|
||||
providers: [
|
||||
{ provide: MatDialogRef, useValue: dialogRef }
|
||||
]
|
||||
});
|
||||
|
||||
// entryComponents are not supported yet on TestBed, that is why this ugly workaround:
|
||||
// https://github.com/angular/angular/issues/10760
|
||||
TestBed.overrideModule(BrowserDynamicTestingModule, {
|
||||
set: { entryComponents: [FolderDialogComponent] }
|
||||
});
|
||||
|
||||
TestBed.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(FolderDialogComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
||||
nodesApi = TestBed.get(NodesApiService);
|
||||
|
||||
translationService = TestBed.get(TranslationService);
|
||||
spyOn(translationService, 'get').and.returnValue(Observable.of('message'));
|
||||
it('should init form with folder name and description', () => {
|
||||
expect(component.name).toBe('folder-name');
|
||||
expect(component.description).toBe('folder-description');
|
||||
});
|
||||
|
||||
describe('Edit', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
component.data = {
|
||||
folder: {
|
||||
id: 'node-id',
|
||||
name: 'folder-name',
|
||||
properties: {
|
||||
['cm:description']: 'folder-description'
|
||||
}
|
||||
}
|
||||
};
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should have the proper title', () => {
|
||||
it('should have the proper title', () => {
|
||||
const title = fixture.debugElement.query(By.css('[mat-dialog-title]'));
|
||||
expect(title === null).toBe(false);
|
||||
expect(title.nativeElement.innerText.trim()).toBe('CORE.FOLDER_DIALOG.EDIT_FOLDER_TITLE');
|
||||
});
|
||||
|
||||
it('should init form with folder name and description', () => {
|
||||
expect(component.name).toBe('folder-name');
|
||||
expect(component.description).toBe('folder-description');
|
||||
});
|
||||
it('should update form input', () => {
|
||||
component.form.controls['name'].setValue('folder-name-update');
|
||||
component.form.controls['description'].setValue('folder-description-update');
|
||||
|
||||
it('should update form input', () => {
|
||||
component.form.controls['name'].setValue('folder-name-update');
|
||||
component.form.controls['description'].setValue('folder-description-update');
|
||||
expect(component.name).toBe('folder-name-update');
|
||||
expect(component.description).toBe('folder-description-update');
|
||||
});
|
||||
|
||||
expect(component.name).toBe('folder-name-update');
|
||||
expect(component.description).toBe('folder-description-update');
|
||||
});
|
||||
it('should submit updated values if form is valid', () => {
|
||||
spyOn(nodesApi, 'updateNode').and.returnValue(Observable.of({}));
|
||||
|
||||
it('should submit updated values if form is valid', () => {
|
||||
spyOn(nodesApi, 'updateNode').and.returnValue(Observable.of({}));
|
||||
component.form.controls['name'].setValue('folder-name-update');
|
||||
component.form.controls['description'].setValue('folder-description-update');
|
||||
|
||||
component.form.controls['name'].setValue('folder-name-update');
|
||||
component.form.controls['description'].setValue('folder-description-update');
|
||||
component.submit();
|
||||
|
||||
component.submit();
|
||||
|
||||
expect(nodesApi.updateNode).toHaveBeenCalledWith(
|
||||
'node-id',
|
||||
{
|
||||
name: 'folder-name-update',
|
||||
properties: {
|
||||
'cm:title': 'folder-name-update',
|
||||
'cm:description': 'folder-description-update'
|
||||
}
|
||||
expect(nodesApi.updateNode).toHaveBeenCalledWith(
|
||||
'node-id',
|
||||
{
|
||||
name: 'folder-name-update',
|
||||
properties: {
|
||||
'cm:title': 'folder-name-update',
|
||||
'cm:description': 'folder-description-update'
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('should call dialog to close with form data when submit is succesfluly', () => {
|
||||
const folder = {
|
||||
data: 'folder-data'
|
||||
};
|
||||
it('should call dialog to close with form data when submit is successfully', () => {
|
||||
const folder = {
|
||||
data: 'folder-data'
|
||||
};
|
||||
|
||||
spyOn(nodesApi, 'updateNode').and.returnValue(Observable.of(folder));
|
||||
spyOn(nodesApi, 'updateNode').and.returnValue(Observable.of(folder));
|
||||
|
||||
component.submit();
|
||||
component.submit();
|
||||
|
||||
expect(dialogRef.close).toHaveBeenCalledWith(folder);
|
||||
});
|
||||
expect(dialogRef.close).toHaveBeenCalledWith(folder);
|
||||
});
|
||||
|
||||
it('should emit success output event with folder when submit is succesfull', async(() => {
|
||||
it('should emit success output event with folder when submit is succesfull', async(() => {
|
||||
const folder = { data: 'folder-data' };
|
||||
let expectedNode = null;
|
||||
|
||||
@@ -233,79 +131,79 @@ describe('FolderDialogComponent', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not submit if form is invalid', () => {
|
||||
spyOn(nodesApi, 'updateNode');
|
||||
it('should not submit if form is invalid', () => {
|
||||
spyOn(nodesApi, 'updateNode');
|
||||
|
||||
component.form.controls['name'].setValue('');
|
||||
component.form.controls['description'].setValue('');
|
||||
component.form.controls['name'].setValue('');
|
||||
component.form.controls['description'].setValue('');
|
||||
|
||||
component.submit();
|
||||
component.submit();
|
||||
|
||||
expect(component.form.valid).toBe(false);
|
||||
expect(nodesApi.updateNode).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not call dialog to close if submit fails', () => {
|
||||
spyOn(nodesApi, 'updateNode').and.returnValue(Observable.throw('error'));
|
||||
spyOn(component, 'handleError').and.callFake(val => val);
|
||||
|
||||
component.submit();
|
||||
|
||||
expect(component.handleError).toHaveBeenCalled();
|
||||
expect(dialogRef.close).not.toHaveBeenCalled();
|
||||
});
|
||||
expect(component.form.valid).toBe(false);
|
||||
expect(nodesApi.updateNode).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
describe('Create', () => {
|
||||
beforeEach(() => {
|
||||
component.data = {
|
||||
parentNodeId: 'parentNodeId',
|
||||
folder: null
|
||||
};
|
||||
fixture.detectChanges();
|
||||
});
|
||||
it('should not call dialog to close if submit fails', () => {
|
||||
spyOn(nodesApi, 'updateNode').and.returnValue(Observable.throw('error'));
|
||||
spyOn(component, 'handleError').and.callFake(val => val);
|
||||
|
||||
it('should have the proper title', () => {
|
||||
const title = fixture.debugElement.query(By.css('[mat-dialog-title]'));
|
||||
expect(title === null).toBe(false);
|
||||
expect(title.nativeElement.innerText.trim()).toBe('CORE.FOLDER_DIALOG.CREATE_FOLDER_TITLE');
|
||||
});
|
||||
component.submit();
|
||||
|
||||
it('should init form with empty inputs', () => {
|
||||
expect(component.name).toBe('');
|
||||
expect(component.description).toBe('');
|
||||
});
|
||||
expect(component.handleError).toHaveBeenCalled();
|
||||
expect(dialogRef.close).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
it('should update form input', () => {
|
||||
component.form.controls['name'].setValue('folder-name-update');
|
||||
component.form.controls['description'].setValue('folder-description-update');
|
||||
describe('Create', () => {
|
||||
beforeEach(() => {
|
||||
component.data = {
|
||||
parentNodeId: 'parentNodeId',
|
||||
folder: null
|
||||
};
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
expect(component.name).toBe('folder-name-update');
|
||||
expect(component.description).toBe('folder-description-update');
|
||||
});
|
||||
it('should have the proper title', () => {
|
||||
const title = fixture.debugElement.query(By.css('[mat-dialog-title]'));
|
||||
expect(title === null).toBe(false);
|
||||
expect(title.nativeElement.innerText.trim()).toBe('CORE.FOLDER_DIALOG.CREATE_FOLDER_TITLE');
|
||||
});
|
||||
|
||||
it('should submit updated values if form is valid', () => {
|
||||
spyOn(nodesApi, 'createFolder').and.returnValue(Observable.of({}));
|
||||
it('should init form with empty inputs', () => {
|
||||
expect(component.name).toBe('');
|
||||
expect(component.description).toBe('');
|
||||
});
|
||||
|
||||
component.form.controls['name'].setValue('folder-name-update');
|
||||
component.form.controls['description'].setValue('folder-description-update');
|
||||
it('should update form input', () => {
|
||||
component.form.controls['name'].setValue('folder-name-update');
|
||||
component.form.controls['description'].setValue('folder-description-update');
|
||||
|
||||
component.submit();
|
||||
expect(component.name).toBe('folder-name-update');
|
||||
expect(component.description).toBe('folder-description-update');
|
||||
});
|
||||
|
||||
expect(nodesApi.createFolder).toHaveBeenCalledWith(
|
||||
'parentNodeId',
|
||||
{
|
||||
name: 'folder-name-update',
|
||||
properties: {
|
||||
'cm:title': 'folder-name-update',
|
||||
'cm:description': 'folder-description-update'
|
||||
},
|
||||
nodeType: 'cm:folder'
|
||||
}
|
||||
);
|
||||
});
|
||||
it('should submit updated values if form is valid', () => {
|
||||
spyOn(nodesApi, 'createFolder').and.returnValue(Observable.of({}));
|
||||
|
||||
it('should submit updated values if form is valid (with custom nodeType)', () => {
|
||||
component.form.controls['name'].setValue('folder-name-update');
|
||||
component.form.controls['description'].setValue('folder-description-update');
|
||||
|
||||
component.submit();
|
||||
|
||||
expect(nodesApi.createFolder).toHaveBeenCalledWith(
|
||||
'parentNodeId',
|
||||
{
|
||||
name: 'folder-name-update',
|
||||
properties: {
|
||||
'cm:title': 'folder-name-update',
|
||||
'cm:description': 'folder-description-update'
|
||||
},
|
||||
nodeType: 'cm:folder'
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('should submit updated values if form is valid (with custom nodeType)', () => {
|
||||
spyOn(nodesApi, 'createFolder').and.returnValue(Observable.of({}));
|
||||
|
||||
component.form.controls['name'].setValue('folder-name-update');
|
||||
@@ -325,102 +223,86 @@ describe('FolderDialogComponent', () => {
|
||||
nodeType: 'cm:sushi'
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('should call dialog to close with form data when submit is succesfluly', () => {
|
||||
const folder = {
|
||||
data: 'folder-data'
|
||||
it('should call dialog to close with form data when submit is successfully', () => {
|
||||
const folder = {
|
||||
data: 'folder-data'
|
||||
};
|
||||
|
||||
component.form.controls['name'].setValue('name');
|
||||
component.form.controls['description'].setValue('description');
|
||||
|
||||
spyOn(nodesApi, 'createFolder').and.returnValue(Observable.of(folder));
|
||||
|
||||
component.submit();
|
||||
|
||||
expect(dialogRef.close).toHaveBeenCalledWith(folder);
|
||||
});
|
||||
|
||||
it('should not submit if form is invalid', () => {
|
||||
spyOn(nodesApi, 'createFolder');
|
||||
|
||||
component.form.controls['name'].setValue('');
|
||||
component.form.controls['description'].setValue('');
|
||||
|
||||
component.submit();
|
||||
|
||||
expect(component.form.valid).toBe(false);
|
||||
expect(nodesApi.createFolder).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not call dialog to close if submit fails', () => {
|
||||
spyOn(nodesApi, 'createFolder').and.returnValue(Observable.throw('error'));
|
||||
spyOn(component, 'handleError').and.callFake(val => val);
|
||||
|
||||
component.form.controls['name'].setValue('name');
|
||||
component.form.controls['description'].setValue('description');
|
||||
|
||||
component.submit();
|
||||
|
||||
expect(component.handleError).toHaveBeenCalled();
|
||||
expect(dialogRef.close).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
describe('Error events ', () => {
|
||||
it('should raise error for 409', (done) => {
|
||||
const error = {
|
||||
message: '{ "error": { "statusCode" : 409 } }'
|
||||
};
|
||||
|
||||
component.form.controls['name'].setValue('name');
|
||||
component.form.controls['description'].setValue('description');
|
||||
|
||||
spyOn(nodesApi, 'createFolder').and.returnValue(Observable.of(folder));
|
||||
|
||||
component.submit();
|
||||
|
||||
expect(dialogRef.close).toHaveBeenCalledWith(folder);
|
||||
});
|
||||
|
||||
it('should emit success output event with folder when submit is succesfull', async(() => {
|
||||
const folder = { data: 'folder-data' };
|
||||
let expectedNode = null;
|
||||
|
||||
component.form.controls['name'].setValue('name');
|
||||
component.form.controls['description'].setValue('description');
|
||||
spyOn(nodesApi, 'createFolder').and.returnValue(Observable.of(folder));
|
||||
|
||||
component.success.subscribe((node) => { expectedNode = node; });
|
||||
component.submit();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
expect(expectedNode).toBe(folder);
|
||||
component.error.subscribe((message) => {
|
||||
expect(message).toBe('CORE.MESSAGES.ERRORS.EXISTENT_FOLDER');
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not submit if form is invalid', () => {
|
||||
spyOn(nodesApi, 'createFolder');
|
||||
|
||||
component.form.controls['name'].setValue('');
|
||||
component.form.controls['description'].setValue('');
|
||||
|
||||
component.submit();
|
||||
|
||||
expect(component.form.valid).toBe(false);
|
||||
expect(nodesApi.createFolder).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not call dialog to close if submit fails', () => {
|
||||
spyOn(nodesApi, 'createFolder').and.returnValue(Observable.throw('error'));
|
||||
spyOn(component, 'handleError').and.callFake(val => val);
|
||||
spyOn(nodesApi, 'createFolder').and.returnValue(Observable.throw(error));
|
||||
|
||||
component.form.controls['name'].setValue('name');
|
||||
component.form.controls['description'].setValue('description');
|
||||
|
||||
component.submit();
|
||||
|
||||
expect(component.handleError).toHaveBeenCalled();
|
||||
expect(dialogRef.close).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
describe('Error events ', () => {
|
||||
it('should raise error for 409', (done) => {
|
||||
const error = {
|
||||
message: '{ "error": { "statusCode" : 409 } }'
|
||||
};
|
||||
it('should raise generic error', (done) => {
|
||||
const error = {
|
||||
message: '{ "error": { "statusCode" : 123 } }'
|
||||
};
|
||||
|
||||
component.error.subscribe((message) => {
|
||||
expect(message).toBe('CORE.MESSAGES.ERRORS.EXISTENT_FOLDER');
|
||||
done();
|
||||
});
|
||||
|
||||
spyOn(nodesApi, 'createFolder').and.returnValue(Observable.throw(error));
|
||||
|
||||
component.form.controls['name'].setValue('name');
|
||||
component.form.controls['description'].setValue('description');
|
||||
|
||||
component.submit();
|
||||
component.error.subscribe((message) => {
|
||||
expect(message).toBe('CORE.MESSAGES.ERRORS.GENERIC');
|
||||
done();
|
||||
});
|
||||
|
||||
it('should raise generic error', (done) => {
|
||||
const error = {
|
||||
message: '{ "error": { "statusCode" : 123 } }'
|
||||
};
|
||||
spyOn(nodesApi, 'createFolder').and.returnValue(Observable.throw(error));
|
||||
|
||||
component.error.subscribe((message) => {
|
||||
expect(message).toBe('CORE.MESSAGES.ERRORS.GENERIC');
|
||||
done();
|
||||
});
|
||||
component.form.controls['name'].setValue('name');
|
||||
component.form.controls['description'].setValue('description');
|
||||
|
||||
spyOn(nodesApi, 'createFolder').and.returnValue(Observable.throw(error));
|
||||
|
||||
component.form.controls['name'].setValue('name');
|
||||
component.form.controls['description'].setValue('description');
|
||||
|
||||
component.submit();
|
||||
});
|
||||
component.submit();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
@@ -17,57 +17,38 @@
|
||||
|
||||
import moment from 'moment-es6';
|
||||
|
||||
import { async, TestBed, fakeAsync, tick } from '@angular/core/testing';
|
||||
import { TestBed, fakeAsync, tick } from '@angular/core/testing';
|
||||
import { ComponentFixture } from '@angular/core/testing';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatDialogRef } from '@angular/material';
|
||||
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
import { AlfrescoApiService, TranslationService } from '@alfresco/adf-core';
|
||||
import { AlfrescoApiService, setupTestBed } from '@alfresco/adf-core';
|
||||
import { NodeLockDialogComponent } from './node-lock.dialog';
|
||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||
|
||||
describe('NodeLockDialogComponent', () => {
|
||||
|
||||
let fixture: ComponentFixture<NodeLockDialogComponent>;
|
||||
let component: NodeLockDialogComponent;
|
||||
let translationService: TranslationService;
|
||||
let alfrescoApi: AlfrescoApiService;
|
||||
let expiryDate;
|
||||
const dialogRef = {
|
||||
close: jasmine.createSpy('close')
|
||||
};
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
BrowserDynamicTestingModule
|
||||
],
|
||||
declarations: [
|
||||
NodeLockDialogComponent
|
||||
],
|
||||
providers: [
|
||||
{ provide: MatDialogRef, useValue: dialogRef }
|
||||
]
|
||||
});
|
||||
|
||||
TestBed.overrideModule(BrowserDynamicTestingModule, {
|
||||
set: { entryComponents: [NodeLockDialogComponent] }
|
||||
});
|
||||
|
||||
TestBed.compileComponents();
|
||||
}));
|
||||
setupTestBed({
|
||||
imports: [ContentTestingModule],
|
||||
providers: [
|
||||
{ provide: MatDialogRef, useValue: dialogRef }
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(NodeLockDialogComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
||||
alfrescoApi = TestBed.get(AlfrescoApiService);
|
||||
});
|
||||
|
||||
translationService = TestBed.get(TranslationService);
|
||||
spyOn(translationService, 'get').and.returnValue(Observable.of('message'));
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
describe('Node lock dialog component', () => {
|
||||
|
@@ -15,55 +15,34 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { async, TestBed } from '@angular/core/testing';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture } from '@angular/core/testing';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
|
||||
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
import { ShareDialogComponent } from './share.dialog';
|
||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||
import { setupTestBed } from '@alfresco/adf-core';
|
||||
|
||||
describe('ShareDialogComponent', () => {
|
||||
|
||||
let fixture: ComponentFixture<ShareDialogComponent>;
|
||||
let component: ShareDialogComponent;
|
||||
let dialogRef;
|
||||
const dialogRef = {
|
||||
close: jasmine.createSpy('close')
|
||||
};
|
||||
|
||||
let data: any = {
|
||||
node: { entry: { properties: { 'qshare:sharedId': 'example-link' }, name: 'example-name' } }
|
||||
node: { entry: { properties: { 'qshare:sharedId': 'example-link' }, name: 'example-name' } },
|
||||
baseShareUrl: 'baseShareUrl-example'
|
||||
};
|
||||
|
||||
beforeEach(async(() => {
|
||||
dialogRef = {
|
||||
close: jasmine.createSpy('close')
|
||||
};
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
BrowserDynamicTestingModule
|
||||
],
|
||||
declarations: [
|
||||
ShareDialogComponent
|
||||
],
|
||||
providers: [
|
||||
{ provide: MatDialogRef, useValue: dialogRef },
|
||||
{
|
||||
provide: MAT_DIALOG_DATA,
|
||||
useValue: data
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
TestBed.overrideModule(BrowserDynamicTestingModule, {
|
||||
set: { entryComponents: [ShareDialogComponent] }
|
||||
});
|
||||
|
||||
TestBed.compileComponents();
|
||||
}));
|
||||
setupTestBed({
|
||||
imports: [ContentTestingModule],
|
||||
providers: [
|
||||
{ provide: MatDialogRef, useValue: dialogRef },
|
||||
{ provide: MAT_DIALOG_DATA, useValue: data }
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ShareDialogComponent);
|
||||
@@ -79,7 +58,7 @@ describe('ShareDialogComponent', () => {
|
||||
|
||||
describe('public link creation', () => {
|
||||
|
||||
it('should not create the public link if it alredy present in the node', () => {
|
||||
it('should not create the public link if it already present in the node', () => {
|
||||
let spyCreate = spyOn(component, 'createSharedLinks').and.returnValue(Observable.of(''));
|
||||
|
||||
component.ngOnInit();
|
||||
@@ -87,16 +66,16 @@ describe('ShareDialogComponent', () => {
|
||||
expect(spyCreate).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not create the public link if it alredy present in the node', () => {
|
||||
it('should not create the public link if it already present in the node', () => {
|
||||
component.data = {
|
||||
node: { entry: { name: 'example-name' } }
|
||||
node: { entry: { name: 'example-name' } },
|
||||
baseShareUrl: 'baseShareUrl-example'
|
||||
};
|
||||
|
||||
let spyCreate = spyOn(component, 'createSharedLinks').and.returnValue(Observable.of(''));
|
||||
|
||||
data = {
|
||||
node: { entry: { name: 'example-name' } }
|
||||
node: { entry: { name: 'example-name' } },
|
||||
baseShareUrl: 'baseShareUrl-example'
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user