mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
[AAE-10644] Fix tests that have no expectations - core lib part 2 (#7893)
* [AAE-10644] Fix tests that have no expectations - core lib part 2 * implement improvements
This commit is contained in:
parent
03a888fb5e
commit
499725659b
@ -752,7 +752,8 @@ describe('DataTable', () => {
|
|||||||
dataTable.onRowClick(row, null);
|
dataTable.onRowClick(row, null);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should emit double click if there are two single click in 250ms', (done) => {
|
it('should emit double click if there are two single click in 250ms', fakeAsync(() => {
|
||||||
|
let doubleClickCount = 0;
|
||||||
|
|
||||||
const row = {} as DataRow;
|
const row = {} as DataRow;
|
||||||
dataTable.data = new ObjectDataTableAdapter([], []);
|
dataTable.data = new ObjectDataTableAdapter([], []);
|
||||||
@ -760,7 +761,7 @@ describe('DataTable', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
dataTable.rowDblClick.subscribe(() => {
|
dataTable.rowDblClick.subscribe(() => {
|
||||||
done();
|
doubleClickCount += 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
dataTable.onRowClick(row, null);
|
dataTable.onRowClick(row, null);
|
||||||
@ -768,16 +769,22 @@ describe('DataTable', () => {
|
|||||||
dataTable.onRowClick(row, null);
|
dataTable.onRowClick(row, null);
|
||||||
}
|
}
|
||||||
, 240);
|
, 240);
|
||||||
});
|
|
||||||
|
|
||||||
it('should emit double click if there are more than two single click in 250ms', (done) => {
|
tick(490);
|
||||||
|
|
||||||
|
|
||||||
|
expect(doubleClickCount).toBe(1);
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should emit double click if there are more than two single click in 250ms', fakeAsync(() => {
|
||||||
|
let doubleClickCount = 0;
|
||||||
const row = {} as DataRow;
|
const row = {} as DataRow;
|
||||||
dataTable.data = new ObjectDataTableAdapter([], []);
|
dataTable.data = new ObjectDataTableAdapter([], []);
|
||||||
dataTable.ngOnChanges({});
|
dataTable.ngOnChanges({});
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
dataTable.rowDblClick.subscribe(() => {
|
dataTable.rowDblClick.subscribe(() => {
|
||||||
done();
|
doubleClickCount += 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
dataTable.onRowClick(row, null);
|
dataTable.onRowClick(row, null);
|
||||||
@ -787,9 +794,13 @@ describe('DataTable', () => {
|
|||||||
dataTable.onRowClick(row, null);
|
dataTable.onRowClick(row, null);
|
||||||
}
|
}
|
||||||
, 240);
|
, 240);
|
||||||
});
|
|
||||||
|
|
||||||
it('should emit single click if there are two single click in more than 250ms', (done) => {
|
tick(740);
|
||||||
|
|
||||||
|
expect(doubleClickCount).toBe(1);
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should emit single click if there are two single click in more than 250ms', fakeAsync(() => {
|
||||||
const row = {} as DataRow;
|
const row = {} as DataRow;
|
||||||
let clickCount = 0;
|
let clickCount = 0;
|
||||||
|
|
||||||
@ -799,17 +810,19 @@ describe('DataTable', () => {
|
|||||||
|
|
||||||
dataTable.rowClick.subscribe(() => {
|
dataTable.rowClick.subscribe(() => {
|
||||||
clickCount += 1;
|
clickCount += 1;
|
||||||
if (clickCount === 2) {
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
dataTable.onRowClick(row, null);
|
dataTable.onRowClick(row, null);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
dataTable.onRowClick(row, null);
|
dataTable.onRowClick(row, null);
|
||||||
}
|
}
|
||||||
, 260);
|
, 260);
|
||||||
});
|
|
||||||
|
tick(510);
|
||||||
|
|
||||||
|
expect(clickCount).toBe(2);
|
||||||
|
}));
|
||||||
|
|
||||||
it('should emit row-click dom event', (done) => {
|
it('should emit row-click dom event', (done) => {
|
||||||
const row = {} as DataRow;
|
const row = {} as DataRow;
|
||||||
@ -977,22 +990,6 @@ describe('DataTable', () => {
|
|||||||
expect(dataTable.isSelectAllChecked).toBeFalsy();
|
expect(dataTable.isSelectAllChecked).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reset selection upon data rows change', () => {
|
|
||||||
const data = new ObjectDataTableAdapter([{}, {}, {}], []);
|
|
||||||
|
|
||||||
dataTable.data = data;
|
|
||||||
dataTable.multiselect = true;
|
|
||||||
dataTable.ngAfterContentInit();
|
|
||||||
dataTable.onSelectAllClick({ checked: true } as MatCheckboxChange);
|
|
||||||
|
|
||||||
expect(dataTable.selection.every((entry) => entry.isSelected));
|
|
||||||
|
|
||||||
data.setRows([]);
|
|
||||||
fixture.detectChanges();
|
|
||||||
|
|
||||||
expect(dataTable.selection.every((entry) => !entry.isSelected));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should update rows on "select all" click', () => {
|
it('should update rows on "select all" click', () => {
|
||||||
const data = new ObjectDataTableAdapter([{}, {}, {}], []);
|
const data = new ObjectDataTableAdapter([{}, {}, {}], []);
|
||||||
const rows = data.getRows();
|
const rows = data.getRows();
|
||||||
|
@ -21,7 +21,6 @@ import { By } from '@angular/platform-browser';
|
|||||||
import { NodeDeleteDirective } from './node-delete.directive';
|
import { NodeDeleteDirective } from './node-delete.directive';
|
||||||
import { setupTestBed } from '../testing/setup-test-bed';
|
import { setupTestBed } from '../testing/setup-test-bed';
|
||||||
import { CoreTestingModule } from '../testing/core.testing.module';
|
import { CoreTestingModule } from '../testing/core.testing.module';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
template: `
|
template: `
|
||||||
@ -90,7 +89,6 @@ describe('NodeDeleteDirective', () => {
|
|||||||
|
|
||||||
setupTestBed({
|
setupTestBed({
|
||||||
imports: [
|
imports: [
|
||||||
TranslateModule.forRoot(),
|
|
||||||
CoreTestingModule
|
CoreTestingModule
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
@ -136,85 +134,77 @@ describe('NodeDeleteDirective', () => {
|
|||||||
expect(deleteNodeSpy).not.toHaveBeenCalled();
|
expect(deleteNodeSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should process node successfully', (done) => {
|
it('should process node successfully', async () => {
|
||||||
component.selection = [{ entry: { id: '1', name: 'name1' } }];
|
component.selection = [{ entry: { id: '1', name: 'name1' } }];
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
disposableDelete = component.deleteDirective.delete.subscribe((message) => {
|
disposableDelete = component.deleteDirective.delete.subscribe((message) => {
|
||||||
expect(message).toBe(
|
expect(message).toBe(
|
||||||
'CORE.DELETE_NODE.SINGULAR'
|
'CORE.DELETE_NODE.SINGULAR'
|
||||||
);
|
);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
element.nativeElement.click();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
element.nativeElement.click();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should notify failed node deletion', (done) => {
|
it('should notify failed node deletion', async () => {
|
||||||
deleteNodeSpy.and.returnValue(Promise.reject('error'));
|
deleteNodeSpy.and.returnValue(Promise.reject('error'));
|
||||||
|
|
||||||
component.selection = [{ entry: { id: '1', name: 'name1' } }];
|
component.selection = [{ entry: { id: '1', name: 'name1' } }];
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
disposableDelete = component.deleteDirective.delete.subscribe((message) => {
|
disposableDelete = component.deleteDirective.delete.subscribe((message) => {
|
||||||
expect(message).toBe(
|
expect(message).toBe(
|
||||||
'CORE.DELETE_NODE.ERROR_SINGULAR'
|
'CORE.DELETE_NODE.ERROR_SINGULAR'
|
||||||
);
|
);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
element.nativeElement.click();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
element.nativeElement.click();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should notify nodes deletion', (done) => {
|
it('should notify nodes deletion', async () => {
|
||||||
component.selection = [
|
component.selection = [
|
||||||
{ entry: { id: '1', name: 'name1' } },
|
{ entry: { id: '1', name: 'name1' } },
|
||||||
{ entry: { id: '2', name: 'name2' } }
|
{ entry: { id: '2', name: 'name2' } }
|
||||||
];
|
];
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
disposableDelete = component.deleteDirective.delete.subscribe((message) => {
|
disposableDelete = component.deleteDirective.delete.subscribe((message) => {
|
||||||
expect(message).toBe(
|
expect(message).toBe(
|
||||||
'CORE.DELETE_NODE.PLURAL'
|
'CORE.DELETE_NODE.PLURAL'
|
||||||
);
|
);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
element.nativeElement.click();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
element.nativeElement.click();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should notify failed nodes deletion', (done) => {
|
it('should notify failed nodes deletion', async () => {
|
||||||
deleteNodeSpy.and.returnValue(Promise.reject('error'));
|
deleteNodeSpy.and.returnValue(Promise.reject('error'));
|
||||||
|
|
||||||
component.selection = [
|
component.selection = [
|
||||||
{ entry: { id: '1', name: 'name1' } },
|
{ entry: { id: '1', name: 'name1' } },
|
||||||
{ entry: { id: '2', name: 'name2' } }
|
{ entry: { id: '2', name: 'name2' } }
|
||||||
];
|
];
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
disposableDelete = component.deleteDirective.delete.subscribe((message) => {
|
disposableDelete = component.deleteDirective.delete.subscribe((message) => {
|
||||||
expect(message).toBe(
|
expect(message).toBe(
|
||||||
'CORE.DELETE_NODE.ERROR_PLURAL'
|
'CORE.DELETE_NODE.ERROR_PLURAL'
|
||||||
);
|
);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
element.nativeElement.click();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
element.nativeElement.click();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should notify partial deletion when only one node is successful', (done) => {
|
it('should notify partial deletion when only one node is successful', async () => {
|
||||||
deleteNodeSpy.and.callFake((id) => {
|
deleteNodeSpy.and.callFake((id) => {
|
||||||
if (id === '1') {
|
if (id === '1') {
|
||||||
return Promise.reject('error');
|
return Promise.reject('error');
|
||||||
@ -227,22 +217,20 @@ describe('NodeDeleteDirective', () => {
|
|||||||
{ entry: { id: '1', name: 'name1' } },
|
{ entry: { id: '1', name: 'name1' } },
|
||||||
{ entry: { id: '2', name: 'name2' } }
|
{ entry: { id: '2', name: 'name2' } }
|
||||||
];
|
];
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
disposableDelete = component.deleteDirective.delete.subscribe((message) => {
|
disposableDelete = component.deleteDirective.delete.subscribe((message) => {
|
||||||
expect(message).toBe(
|
expect(message).toBe(
|
||||||
'CORE.DELETE_NODE.PARTIAL_SINGULAR'
|
'CORE.DELETE_NODE.PARTIAL_SINGULAR'
|
||||||
);
|
);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
element.nativeElement.click();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
element.nativeElement.click();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should notify partial deletion when some nodes are successful', (done) => {
|
it('should notify partial deletion when some nodes are successful', async () => {
|
||||||
deleteNodeSpy.and.callFake((id) => {
|
deleteNodeSpy.and.callFake((id) => {
|
||||||
if (id === '1') {
|
if (id === '1') {
|
||||||
return Promise.reject(null);
|
return Promise.reject(null);
|
||||||
@ -256,55 +244,47 @@ describe('NodeDeleteDirective', () => {
|
|||||||
{ entry: { id: '2', name: 'name2' } },
|
{ entry: { id: '2', name: 'name2' } },
|
||||||
{ entry: { id: '3', name: 'name3' } }
|
{ entry: { id: '3', name: 'name3' } }
|
||||||
];
|
];
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
disposableDelete = component.deleteDirective.delete.subscribe((message) => {
|
disposableDelete = component.deleteDirective.delete.subscribe((message) => {
|
||||||
expect(message).toBe(
|
expect(message).toBe(
|
||||||
'CORE.DELETE_NODE.PARTIAL_PLURAL'
|
'CORE.DELETE_NODE.PARTIAL_PLURAL'
|
||||||
);
|
);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
fixture.detectChanges();
|
|
||||||
|
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
element.nativeElement.click();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should emit event when delete is done', (done) => {
|
|
||||||
component.selection = [{ entry: { id: '1', name: 'name1' } }];
|
|
||||||
fixture.detectChanges();
|
|
||||||
|
|
||||||
element.nativeElement.click();
|
element.nativeElement.click();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
disposableDelete = component.deleteDirective.delete.subscribe(() => {
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should disable the button if no node are selected', (done) => {
|
it('should emit event when delete is done', async () => {
|
||||||
|
component.selection = [{ entry: { id: '1', name: 'name1' } }];
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
disposableDelete = component.deleteDirective.delete.subscribe((node) => {
|
||||||
|
expect(node).toEqual('CORE.DELETE_NODE.SINGULAR');
|
||||||
|
});
|
||||||
|
|
||||||
|
element.nativeElement.click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should disable the button if no node are selected', () => {
|
||||||
component.selection = [];
|
component.selection = [];
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
fixture.whenStable().then(() => {
|
expect(element.nativeElement.disabled).toEqual(true);
|
||||||
expect(element.nativeElement.disabled).toEqual(true);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should disable the button if selected node is null', (done) => {
|
it('should disable the button if selected node is null', () => {
|
||||||
component.selection = null;
|
component.selection = null;
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
expect(element.nativeElement.disabled).toEqual(true);
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
expect(element.nativeElement.disabled).toEqual(true);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should enable the button if nodes are selected', (done) => {
|
it('should enable the button if nodes are selected', () => {
|
||||||
component.selection = [
|
component.selection = [
|
||||||
{ entry: { id: '1', name: 'name1' } },
|
{ entry: { id: '1', name: 'name1' } },
|
||||||
{ entry: { id: '2', name: 'name2' } },
|
{ entry: { id: '2', name: 'name2' } },
|
||||||
@ -312,14 +292,10 @@ describe('NodeDeleteDirective', () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
expect(element.nativeElement.disabled).toEqual(false);
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
expect(element.nativeElement.disabled).toEqual(false);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not enable the button if adf-check-allowable-operation is present', (done) => {
|
it('should not enable the button if adf-check-allowable-operation is present', () => {
|
||||||
const elementWithPermissions = fixtureWithPermissions.debugElement.query(By.directive(NodeDeleteDirective));
|
const elementWithPermissions = fixtureWithPermissions.debugElement.query(By.directive(NodeDeleteDirective));
|
||||||
const componentWithPermissions = fixtureWithPermissions.componentInstance;
|
const componentWithPermissions = fixtureWithPermissions.componentInstance;
|
||||||
|
|
||||||
@ -335,16 +311,12 @@ describe('NodeDeleteDirective', () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
fixtureWithPermissions.detectChanges();
|
fixtureWithPermissions.detectChanges();
|
||||||
|
expect(elementWithPermissions.nativeElement.disabled).toEqual(false);
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
expect(elementWithPermissions.nativeElement.disabled).toEqual(false);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Permanent', () => {
|
describe('Permanent', () => {
|
||||||
|
|
||||||
it('should call the api with permanent delete option if permanent directive input is true', (done) => {
|
it('should call the api with permanent delete option if permanent directive input is true', () => {
|
||||||
fixtureWithPermanentComponent.detectChanges();
|
fixtureWithPermanentComponent.detectChanges();
|
||||||
|
|
||||||
componentWithPermanentDelete.selection = [
|
componentWithPermanentDelete.selection = [
|
||||||
@ -352,16 +324,12 @@ describe('NodeDeleteDirective', () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
fixtureWithPermanentComponent.detectChanges();
|
fixtureWithPermanentComponent.detectChanges();
|
||||||
|
|
||||||
elementWithPermanentDelete.nativeElement.click();
|
elementWithPermanentDelete.nativeElement.click();
|
||||||
|
|
||||||
fixture.whenStable().then(() => {
|
expect(deleteNodePermanentSpy).toHaveBeenCalledWith('1', { permanent: true });
|
||||||
expect(deleteNodePermanentSpy).toHaveBeenCalledWith('1', { permanent: true });
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call the trashcan api if permanent directive input is true and the file is already in the trashcan ', (done) => {
|
it('should call the trashcan api if permanent directive input is true and the file is already in the trashcan ', () => {
|
||||||
fixtureWithPermanentComponent.detectChanges();
|
fixtureWithPermanentComponent.detectChanges();
|
||||||
|
|
||||||
componentWithPermanentDelete.selection = [
|
componentWithPermanentDelete.selection = [
|
||||||
@ -369,15 +337,10 @@ describe('NodeDeleteDirective', () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
fixtureWithPermanentComponent.detectChanges();
|
fixtureWithPermanentComponent.detectChanges();
|
||||||
|
|
||||||
elementWithPermanentDelete.nativeElement.click();
|
elementWithPermanentDelete.nativeElement.click();
|
||||||
|
|
||||||
fixture.whenStable().then(() => {
|
expect(purgeDeletedNodePermanentSpy).toHaveBeenCalledWith('1');
|
||||||
expect(purgeDeletedNodePermanentSpy).toHaveBeenCalledWith('1');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { ElementRef } from '@angular/core';
|
import { ElementRef } from '@angular/core';
|
||||||
|
import { fakeAsync, tick } from '@angular/core/testing';
|
||||||
import { UploadDirective } from './upload.directive';
|
import { UploadDirective } from './upload.directive';
|
||||||
|
|
||||||
describe('UploadDirective', () => {
|
describe('UploadDirective', () => {
|
||||||
@ -106,18 +107,19 @@ describe('UploadDirective', () => {
|
|||||||
expect(event.preventDefault).not.toHaveBeenCalled();
|
expect(event.preventDefault).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should raise upload-files event on files drop', (done) => {
|
it('should raise upload-files event on files drop', fakeAsync(() => {
|
||||||
directive.enabled = true;
|
directive.enabled = true;
|
||||||
const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
|
const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
|
||||||
spyOn(directive, 'getDataTransfer').and.returnValue({} as any);
|
spyOn(directive, 'getDataTransfer').and.returnValue({} as any);
|
||||||
spyOn(directive, 'getFilesDropped').and.returnValue(Promise.resolve([{}, {}]));
|
spyOn(directive, 'getFilesDropped').and.returnValue(Promise.resolve([{}, {}]));
|
||||||
spyOn(nativeElement, 'dispatchEvent').and.callFake((_) => {
|
spyOn(nativeElement, 'dispatchEvent').and.callFake((customEvent) => {
|
||||||
done();
|
expect(customEvent).toBeTruthy();
|
||||||
});
|
});
|
||||||
directive.onDrop(event);
|
directive.onDrop(event);
|
||||||
});
|
tick();
|
||||||
|
}));
|
||||||
|
|
||||||
it('should provide dropped files in upload-files event', (done) => {
|
it('should provide dropped files in upload-files event', fakeAsync(() => {
|
||||||
directive.enabled = true;
|
directive.enabled = true;
|
||||||
const files = [{}];
|
const files = [{}];
|
||||||
const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
|
const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
|
||||||
@ -127,10 +129,11 @@ describe('UploadDirective', () => {
|
|||||||
spyOn(nativeElement, 'dispatchEvent').and.callFake((e) => {
|
spyOn(nativeElement, 'dispatchEvent').and.callFake((e) => {
|
||||||
expect(e.detail.files.length).toBe(1);
|
expect(e.detail.files.length).toBe(1);
|
||||||
expect(e.detail.files[0]).toBe(files[0]);
|
expect(e.detail.files[0]).toBe(files[0]);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
directive.onDrop(event);
|
directive.onDrop(event);
|
||||||
});
|
tick();
|
||||||
|
}));
|
||||||
|
|
||||||
it('should reset input value after file upload', () => {
|
it('should reset input value after file upload', () => {
|
||||||
directive.enabled = true;
|
directive.enabled = true;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { FormFieldTypes } from '../core/form-field-types';
|
import { FormFieldTypes } from '../core/form-field-types';
|
||||||
import { FormFieldModel } from '../core/form-field.model';
|
import { FormFieldModel } from '../core/form-field.model';
|
||||||
import { FormModel } from '../core/form.model';
|
import { FormModel } from '../core/form.model';
|
||||||
@ -92,15 +92,14 @@ describe('CheckboxWidgetComponent', () => {
|
|||||||
expect(asterisk.textContent).toEqual('*');
|
expect(asterisk.textContent).toEqual('*');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be checked if boolean true is passed', fakeAsync(() => {
|
it('should be checked if boolean true is passed', async () => {
|
||||||
widget.field.value = true;
|
widget.field.value = true;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
fixture.whenStable().then(() => {
|
await fixture.whenStable();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const checkbox = fixture.debugElement.nativeElement.querySelector('mat-checkbox input');
|
const checkbox = fixture.debugElement.nativeElement.querySelector('mat-checkbox input');
|
||||||
expect(checkbox.getAttribute('aria-checked')).toBe('true');
|
expect(checkbox.getAttribute('aria-checked')).toBe('true');
|
||||||
});
|
});
|
||||||
}));
|
|
||||||
|
|
||||||
it('should not be checked if false is passed', async () => {
|
it('should not be checked if false is passed', async () => {
|
||||||
widget.field.value = false;
|
widget.field.value = false;
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { SimpleChange } from '@angular/core';
|
import { SimpleChange } from '@angular/core';
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { ContentService } from '../../../../services';
|
import { ContentService } from '../../../../services';
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
@ -99,7 +99,7 @@ describe('ContentWidgetComponent', () => {
|
|||||||
expect(content).toBeDefined();
|
expect(content).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should load the thumbnail preview of the png image', (done) => {
|
it('should load the thumbnail preview of the png image', fakeAsync(() => {
|
||||||
const blob = createFakeImageBlob();
|
const blob = createFakeImageBlob();
|
||||||
spyOn(processContentService, 'getFileRawContent').and.returnValue(of(blob));
|
spyOn(processContentService, 'getFileRawContent').and.returnValue(of(blob));
|
||||||
|
|
||||||
@ -108,12 +108,9 @@ describe('ContentWidgetComponent', () => {
|
|||||||
expect(res).toBeDefined();
|
expect(res).toBeDefined();
|
||||||
expect(res.changingThisBreaksApplicationSecurity).toBeDefined();
|
expect(res.changingThisBreaksApplicationSecurity).toBeDefined();
|
||||||
expect(res.changingThisBreaksApplicationSecurity).toContain('blob');
|
expect(res.changingThisBreaksApplicationSecurity).toContain('blob');
|
||||||
fixture.whenStable()
|
|
||||||
.then(() => {
|
const thumbnailPreview: any = element.querySelector('#thumbnailPreview');
|
||||||
const thumbnailPreview: any = element.querySelector('#thumbnailPreview');
|
expect(thumbnailPreview.src).toContain('blob');
|
||||||
expect(thumbnailPreview.src).toContain('blob');
|
|
||||||
});
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const contentId = 1;
|
const contentId = 1;
|
||||||
@ -140,9 +137,9 @@ describe('ContentWidgetComponent', () => {
|
|||||||
thumbnailStatus: 'unsupported'
|
thumbnailStatus: 'unsupported'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
|
|
||||||
it('should load the thumbnail preview of a pdf', (done) => {
|
it('should load the thumbnail preview of a pdf', fakeAsync(() => {
|
||||||
const blob = createFakePdfBlob();
|
const blob = createFakePdfBlob();
|
||||||
spyOn(processContentService, 'getContentThumbnail').and.returnValue(of(blob));
|
spyOn(processContentService, 'getContentThumbnail').and.returnValue(of(blob));
|
||||||
|
|
||||||
@ -151,12 +148,9 @@ describe('ContentWidgetComponent', () => {
|
|||||||
expect(res).toBeDefined();
|
expect(res).toBeDefined();
|
||||||
expect(res.changingThisBreaksApplicationSecurity).toBeDefined();
|
expect(res.changingThisBreaksApplicationSecurity).toBeDefined();
|
||||||
expect(res.changingThisBreaksApplicationSecurity).toContain('blob');
|
expect(res.changingThisBreaksApplicationSecurity).toContain('blob');
|
||||||
fixture.whenStable()
|
|
||||||
.then(() => {
|
const thumbnailPreview: any = element.querySelector('#thumbnailPreview');
|
||||||
const thumbnailPreview: any = element.querySelector('#thumbnailPreview');
|
expect(thumbnailPreview.src).toContain('blob');
|
||||||
expect(thumbnailPreview.src).toContain('blob');
|
|
||||||
});
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const contentId = 1;
|
const contentId = 1;
|
||||||
@ -183,9 +177,9 @@ describe('ContentWidgetComponent', () => {
|
|||||||
thumbnailStatus: 'created'
|
thumbnailStatus: 'created'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
|
|
||||||
it('should show unsupported preview with unsupported file', (done) => {
|
it('should show unsupported preview with unsupported file', fakeAsync(() => {
|
||||||
|
|
||||||
const contentId = 1;
|
const contentId = 1;
|
||||||
const change = new SimpleChange(null, contentId, true);
|
const change = new SimpleChange(null, contentId, true);
|
||||||
@ -193,13 +187,9 @@ describe('ContentWidgetComponent', () => {
|
|||||||
|
|
||||||
component.contentLoaded.subscribe(() => {
|
component.contentLoaded.subscribe(() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
fixture.whenStable()
|
const thumbnailPreview: any = element.querySelector('#unsupported-thumbnail');
|
||||||
.then(() => {
|
expect(thumbnailPreview).toBeDefined();
|
||||||
const thumbnailPreview: any = element.querySelector('#unsupported-thumbnail');
|
expect(element.querySelector('div.upload-widget__content-text').innerHTML).toEqual('FakeBlob.zip');
|
||||||
expect(thumbnailPreview).toBeDefined();
|
|
||||||
expect(element.querySelector('div.upload-widget__content-text').innerHTML).toEqual('FakeBlob.zip');
|
|
||||||
});
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
@ -222,9 +212,9 @@ describe('ContentWidgetComponent', () => {
|
|||||||
thumbnailStatus: 'unsupported'
|
thumbnailStatus: 'unsupported'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
|
|
||||||
it('should open the viewer when the view button is clicked', (done) => {
|
it('should open the viewer when the view button is clicked', () => {
|
||||||
const blob = createFakePdfBlob();
|
const blob = createFakePdfBlob();
|
||||||
spyOn(processContentService, 'getContentPreview').and.returnValue(of(blob));
|
spyOn(processContentService, 'getContentPreview').and.returnValue(of(blob));
|
||||||
spyOn(processContentService, 'getFileRawContent').and.returnValue(of(blob));
|
spyOn(processContentService, 'getFileRawContent').and.returnValue(of(blob));
|
||||||
@ -252,7 +242,6 @@ describe('ContentWidgetComponent', () => {
|
|||||||
expect(content.contentBlob).toBe(blob);
|
expect(content.contentBlob).toBe(blob);
|
||||||
expect(content.mimeType).toBe('application/pdf');
|
expect(content.mimeType).toBe('application/pdf');
|
||||||
expect(content.name).toBe('FakeBlob.pdf');
|
expect(content.name).toBe('FakeBlob.pdf');
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@ -288,10 +277,7 @@ describe('ContentWidgetComponent', () => {
|
|||||||
const downloadButton: any = element.querySelector('#download');
|
const downloadButton: any = element.querySelector('#download');
|
||||||
downloadButton.click();
|
downloadButton.click();
|
||||||
|
|
||||||
fixture.whenStable()
|
expect(serviceContent.downloadBlob).toHaveBeenCalledWith(blob, 'FakeBlob.pdf');
|
||||||
.then(() => {
|
|
||||||
expect(serviceContent.downloadBlob).toHaveBeenCalledWith(blob, 'FakeBlob.pdf');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -30,8 +30,6 @@ import { UploadWidgetContentLinkModel } from './upload-widget-content-link.model
|
|||||||
import { AlfrescoApiService } from '../../../../services';
|
import { AlfrescoApiService } from '../../../../services';
|
||||||
import { TestBed } from '@angular/core/testing';
|
import { TestBed } from '@angular/core/testing';
|
||||||
import { CoreTestingModule, setupTestBed } from '../../../../testing';
|
import { CoreTestingModule, setupTestBed } from '../../../../testing';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
|
||||||
import { CoreModule } from '../../../../core.module';
|
|
||||||
|
|
||||||
describe('FormModel', () => {
|
describe('FormModel', () => {
|
||||||
let formService: FormService;
|
let formService: FormService;
|
||||||
@ -39,8 +37,6 @@ describe('FormModel', () => {
|
|||||||
|
|
||||||
setupTestBed({
|
setupTestBed({
|
||||||
imports: [
|
imports: [
|
||||||
TranslateModule.forRoot(),
|
|
||||||
CoreModule.forRoot(),
|
|
||||||
CoreTestingModule
|
CoreTestingModule
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@ -284,18 +280,22 @@ describe('FormModel', () => {
|
|||||||
expect(form.outcomes[1].isSystem).toBeFalsy();
|
expect(form.outcomes[1].isSystem).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should raise validation event when validating form', (done) => {
|
it('should raise validation event when validating form', () => {
|
||||||
const form = new FormModel({}, null, false, formService);
|
const form = new FormModel({}, null, false, formService);
|
||||||
|
|
||||||
formService.validateForm.subscribe(() => done());
|
formService.validateForm.subscribe((validateFormEvent) =>
|
||||||
|
expect(validateFormEvent).toBeTruthy()
|
||||||
|
);
|
||||||
form.validateForm();
|
form.validateForm();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should raise validation event when validating field', (done) => {
|
it('should raise validation event when validating field', () => {
|
||||||
const form = new FormModel({}, null, false, formService);
|
const form = new FormModel({}, null, false, formService);
|
||||||
const field = jasmine.createSpyObj('FormFieldModel', ['validate']);
|
const field = jasmine.createSpyObj('FormFieldModel', ['validate']);
|
||||||
|
|
||||||
formService.validateFormField.subscribe(() => done());
|
formService.validateFormField.subscribe((validateFormFieldEvent) =>
|
||||||
|
expect(validateFormFieldEvent).toBeTruthy()
|
||||||
|
);
|
||||||
form.validateField(field);
|
form.validateField(field);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -109,9 +109,7 @@ export class FormModel implements ProcessFormModel {
|
|||||||
this.enableFixedSpace = enableFixedSpace ? true : false;
|
this.enableFixedSpace = enableFixedSpace ? true : false;
|
||||||
this.confirmMessage = json.confirmMessage || {};
|
this.confirmMessage = json.confirmMessage || {};
|
||||||
|
|
||||||
this.tabs = (json.tabs || []).map((tabJson) => {
|
this.tabs = (json.tabs || []).map((tabJson) => new TabModel(this, tabJson));
|
||||||
return new TabModel(this, tabJson);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.fields = this.parseRootFields(json);
|
this.fields = this.parseRootFields(json);
|
||||||
this.fieldsCache = this.getFormFields();
|
this.fieldsCache = this.getFormFields();
|
||||||
|
@ -117,21 +117,19 @@ describe('DateTimeWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be marked as invalid after interaction', async () => {
|
it('should be marked as invalid after interaction', () => {
|
||||||
const dateTimeInput = fixture.nativeElement.querySelector('input');
|
const dateTimeInput = fixture.nativeElement.querySelector('input');
|
||||||
expect(fixture.nativeElement.querySelector('.adf-invalid')).toBeFalsy();
|
expect(fixture.nativeElement.querySelector('.adf-invalid')).toBeFalsy();
|
||||||
|
|
||||||
dateTimeInput.dispatchEvent(new Event('blur'));
|
dateTimeInput.dispatchEvent(new Event('blur'));
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
|
||||||
|
|
||||||
expect(fixture.nativeElement.querySelector('.adf-invalid')).toBeTruthy();
|
expect(fixture.nativeElement.querySelector('.adf-invalid')).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to display label with asterisk', async () => {
|
it('should be able to display label with asterisk', () => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
|
||||||
|
|
||||||
const asterisk: HTMLElement = element.querySelector('.adf-asterisk');
|
const asterisk: HTMLElement = element.querySelector('.adf-asterisk');
|
||||||
|
|
||||||
@ -142,7 +140,7 @@ describe('DateTimeWidgetComponent', () => {
|
|||||||
|
|
||||||
describe('template check', () => {
|
describe('template check', () => {
|
||||||
|
|
||||||
it('should show visible date widget', async () => {
|
it('should show visible date widget', () => {
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
id: 'date-field-id',
|
id: 'date-field-id',
|
||||||
name: 'date-name',
|
name: 'date-name',
|
||||||
@ -152,15 +150,15 @@ describe('DateTimeWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
|
||||||
|
|
||||||
expect(element.querySelector('#date-field-id')).toBeDefined();
|
expect(element.querySelector('#date-field-id')).toBeDefined();
|
||||||
expect(element.querySelector('#date-field-id')).not.toBeNull();
|
expect(element.querySelector('#date-field-id')).not.toBeNull();
|
||||||
|
|
||||||
const dateElement: any = element.querySelector('#date-field-id');
|
const dateElement: any = element.querySelector('#date-field-id');
|
||||||
expect(dateElement.value).toBe('30-11-9999 10:30 AM');
|
expect(dateElement.value).toBe('30-11-9999 10:30 AM');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show the correct format type', async () => {
|
it('should show the correct format type', () => {
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
id: 'date-field-id',
|
id: 'date-field-id',
|
||||||
name: 'date-name',
|
name: 'date-name',
|
||||||
@ -171,15 +169,15 @@ describe('DateTimeWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
|
||||||
|
|
||||||
expect(element.querySelector('#date-field-id')).toBeDefined();
|
expect(element.querySelector('#date-field-id')).toBeDefined();
|
||||||
expect(element.querySelector('#date-field-id')).not.toBeNull();
|
expect(element.querySelector('#date-field-id')).not.toBeNull();
|
||||||
|
|
||||||
const dateElement: any = element.querySelector('#date-field-id');
|
const dateElement: any = element.querySelector('#date-field-id');
|
||||||
expect(dateElement.value).toContain('12-30-9999 10:30 AM');
|
expect(dateElement.value).toContain('12-30-9999 10:30 AM');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should disable date button when is readonly', async () => {
|
it('should disable date button when is readonly', () => {
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
id: 'date-field-id',
|
id: 'date-field-id',
|
||||||
name: 'date-name',
|
name: 'date-name',
|
||||||
@ -189,20 +187,18 @@ describe('DateTimeWidgetComponent', () => {
|
|||||||
readOnly: 'false'
|
readOnly: 'false'
|
||||||
});
|
});
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
|
||||||
|
|
||||||
let dateButton = element.querySelector<HTMLButtonElement>('button');
|
let dateButton = element.querySelector<HTMLButtonElement>('button');
|
||||||
expect(dateButton.disabled).toBeFalsy();
|
expect(dateButton.disabled).toBeFalsy();
|
||||||
|
|
||||||
widget.field.readOnly = true;
|
widget.field.readOnly = true;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
|
||||||
|
|
||||||
dateButton = element.querySelector<HTMLButtonElement>('button');
|
dateButton = element.querySelector<HTMLButtonElement>('button');
|
||||||
expect(dateButton.disabled).toBeTruthy();
|
expect(dateButton.disabled).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display tooltip when tooltip is set', async () => {
|
it('should display tooltip when tooltip is set', () => {
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
id: 'date-field-id',
|
id: 'date-field-id',
|
||||||
name: 'date-name',
|
name: 'date-name',
|
||||||
@ -214,7 +210,6 @@ describe('DateTimeWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
|
||||||
|
|
||||||
const dateElement: any = element.querySelector('#date-field-id');
|
const dateElement: any = element.querySelector('#date-field-id');
|
||||||
const tooltip = dateElement.getAttribute('ng-reflect-message');
|
const tooltip = dateElement.getAttribute('ng-reflect-message');
|
||||||
@ -234,27 +229,23 @@ describe('DateTimeWidgetComponent', () => {
|
|||||||
field.isVisible = true;
|
field.isVisible = true;
|
||||||
field.dateDisplayFormat = 'MM-DD-YYYY HH:mm A';
|
field.dateDisplayFormat = 'MM-DD-YYYY HH:mm A';
|
||||||
widget.field = field;
|
widget.field = field;
|
||||||
widget.ngOnInit();
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
fixture.whenStable()
|
|
||||||
.then(() => {
|
|
||||||
expect(element.querySelector('#date-field-id')).toBeDefined();
|
|
||||||
expect(element.querySelector('#date-field-id')).not.toBeNull();
|
|
||||||
const dateElement: any = element.querySelector('#date-field-id');
|
|
||||||
expect(dateElement.value).toContain('12-30-9999 10:30 AM');
|
|
||||||
|
|
||||||
widget.field.value = '03-02-2020 12:00 AM';
|
expect(element.querySelector('#date-field-id')).toBeDefined();
|
||||||
|
expect(element.querySelector('#date-field-id')).not.toBeNull();
|
||||||
|
|
||||||
fixture.whenStable()
|
const dateElement: any = element.querySelector('#date-field-id');
|
||||||
.then(() => {
|
expect(dateElement.value).toContain('12-30-9999 10:30 AM');
|
||||||
expect(dateElement.value).toContain('03-02-2020 12:00 AM');
|
|
||||||
});
|
widget.field.value = '03-02-2020 12:00 AM';
|
||||||
});
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(dateElement.value).toContain('03-02-2020 12:00 AM');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when form model has left labels', () => {
|
describe('when form model has left labels', () => {
|
||||||
|
|
||||||
it('should have left labels classes on leftLabels true', async () => {
|
it('should have left labels classes on leftLabels true', () => {
|
||||||
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id', leftLabels: true }), {
|
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id', leftLabels: true }), {
|
||||||
id: 'datetime-id',
|
id: 'datetime-id',
|
||||||
name: 'datetime-name',
|
name: 'datetime-name',
|
||||||
@ -265,7 +256,6 @@ describe('DateTimeWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
|
||||||
|
|
||||||
const widgetContainer = element.querySelector('.adf-left-label-input-container');
|
const widgetContainer = element.querySelector('.adf-left-label-input-container');
|
||||||
expect(widgetContainer).not.toBeNull();
|
expect(widgetContainer).not.toBeNull();
|
||||||
@ -277,7 +267,7 @@ describe('DateTimeWidgetComponent', () => {
|
|||||||
expect(adfLeftLabel).not.toBeNull();
|
expect(adfLeftLabel).not.toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not have left labels classes on leftLabels false', async () => {
|
it('should not have left labels classes on leftLabels false', () => {
|
||||||
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id', leftLabels: false }), {
|
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id', leftLabels: false }), {
|
||||||
id: 'datetime-id',
|
id: 'datetime-id',
|
||||||
name: 'datetime-name',
|
name: 'datetime-name',
|
||||||
@ -288,7 +278,6 @@ describe('DateTimeWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
|
||||||
|
|
||||||
const widgetContainer = element.querySelector('.adf-left-label-input-container');
|
const widgetContainer = element.querySelector('.adf-left-label-input-container');
|
||||||
expect(widgetContainer).toBeNull();
|
expect(widgetContainer).toBeNull();
|
||||||
@ -300,7 +289,7 @@ describe('DateTimeWidgetComponent', () => {
|
|||||||
expect(adfLeftLabel).toBeNull();
|
expect(adfLeftLabel).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not have left labels classes on leftLabels not present', async () => {
|
it('should not have left labels classes on leftLabels not present', () => {
|
||||||
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id' }), {
|
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id' }), {
|
||||||
id: 'datetime-id',
|
id: 'datetime-id',
|
||||||
name: 'datetime-name',
|
name: 'datetime-name',
|
||||||
@ -311,7 +300,6 @@ describe('DateTimeWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
|
||||||
|
|
||||||
const widgetContainer = element.querySelector('.adf-left-label-input-container');
|
const widgetContainer = element.querySelector('.adf-left-label-input-container');
|
||||||
expect(widgetContainer).toBeNull();
|
expect(widgetContainer).toBeNull();
|
||||||
|
@ -105,24 +105,21 @@ describe('DateWidgetComponent', () => {
|
|||||||
type: FormFieldTypes.DATE,
|
type: FormFieldTypes.DATE,
|
||||||
required: true
|
required: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be marked as invalid after interaction', async () => {
|
it('should be marked as invalid after interaction', () => {
|
||||||
const dateInput = fixture.nativeElement.querySelector('input');
|
const dateInput = fixture.nativeElement.querySelector('input');
|
||||||
expect(fixture.nativeElement.querySelector('.adf-invalid')).toBeFalsy();
|
expect(fixture.nativeElement.querySelector('.adf-invalid')).toBeFalsy();
|
||||||
|
|
||||||
dateInput.dispatchEvent(new Event('blur'));
|
dateInput.dispatchEvent(new Event('blur'));
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
|
||||||
|
|
||||||
expect(fixture.nativeElement.querySelector('.adf-invalid')).toBeTruthy();
|
expect(fixture.nativeElement.querySelector('.adf-invalid')).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to display label with asterix', async () => {
|
it('should be able to display label with asterix', () => {
|
||||||
fixture.detectChanges();
|
|
||||||
await fixture.whenStable();
|
|
||||||
|
|
||||||
const asterisk: HTMLElement = element.querySelector('.adf-asterisk');
|
const asterisk: HTMLElement = element.querySelector('.adf-asterisk');
|
||||||
|
|
||||||
expect(asterisk).toBeTruthy();
|
expect(asterisk).toBeTruthy();
|
||||||
@ -137,7 +134,7 @@ describe('DateWidgetComponent', () => {
|
|||||||
TestBed.resetTestingModule();
|
TestBed.resetTestingModule();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show visible date widget', async () => {
|
it('should show visible date widget', () => {
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
id: 'date-field-id',
|
id: 'date-field-id',
|
||||||
name: 'date-name',
|
name: 'date-name',
|
||||||
@ -146,18 +143,17 @@ describe('DateWidgetComponent', () => {
|
|||||||
readOnly: 'false'
|
readOnly: 'false'
|
||||||
});
|
});
|
||||||
widget.field.isVisible = true;
|
widget.field.isVisible = true;
|
||||||
widget.ngOnInit();
|
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
|
||||||
|
|
||||||
expect(element.querySelector('#date-field-id')).toBeDefined();
|
expect(element.querySelector('#date-field-id')).toBeDefined();
|
||||||
expect(element.querySelector('#date-field-id')).not.toBeNull();
|
expect(element.querySelector('#date-field-id')).not.toBeNull();
|
||||||
|
|
||||||
const dateElement: any = element.querySelector('#date-field-id');
|
const dateElement: any = element.querySelector('#date-field-id');
|
||||||
expect(dateElement.value).toContain('9-9-9999');
|
expect(dateElement.value).toContain('9-9-9999');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show the correct format type', async () => {
|
it('should show the correct format type', () => {
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
id: 'date-field-id',
|
id: 'date-field-id',
|
||||||
name: 'date-name',
|
name: 'date-name',
|
||||||
@ -167,18 +163,17 @@ describe('DateWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
widget.field.isVisible = true;
|
widget.field.isVisible = true;
|
||||||
widget.field.dateDisplayFormat = 'MM-DD-YYYY';
|
widget.field.dateDisplayFormat = 'MM-DD-YYYY';
|
||||||
widget.ngOnInit();
|
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
|
||||||
|
|
||||||
expect(element.querySelector('#date-field-id')).toBeDefined();
|
expect(element.querySelector('#date-field-id')).toBeDefined();
|
||||||
expect(element.querySelector('#date-field-id')).not.toBeNull();
|
expect(element.querySelector('#date-field-id')).not.toBeNull();
|
||||||
|
|
||||||
const dateElement: any = element.querySelector('#date-field-id');
|
const dateElement: any = element.querySelector('#date-field-id');
|
||||||
expect(dateElement.value).toContain('12-30-9999');
|
expect(dateElement.value).toContain('12-30-9999');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should disable date button when is readonly', async () => {
|
it('should disable date button when is readonly', () => {
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
id: 'date-field-id',
|
id: 'date-field-id',
|
||||||
name: 'date-name',
|
name: 'date-name',
|
||||||
@ -190,7 +185,6 @@ describe('DateWidgetComponent', () => {
|
|||||||
widget.field.readOnly = false;
|
widget.field.readOnly = false;
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
|
||||||
|
|
||||||
let dateButton = element.querySelector<HTMLButtonElement>('button');
|
let dateButton = element.querySelector<HTMLButtonElement>('button');
|
||||||
expect(dateButton.disabled).toBeFalsy();
|
expect(dateButton.disabled).toBeFalsy();
|
||||||
@ -202,7 +196,7 @@ describe('DateWidgetComponent', () => {
|
|||||||
expect(dateButton.disabled).toBeTruthy();
|
expect(dateButton.disabled).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set isValid to false when the value is not a correct date value', async () => {
|
it('should set isValid to false when the value is not a correct date value', () => {
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
id: 'date-field-id',
|
id: 'date-field-id',
|
||||||
name: 'date-name',
|
name: 'date-name',
|
||||||
@ -212,9 +206,7 @@ describe('DateWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
widget.field.isVisible = true;
|
widget.field.isVisible = true;
|
||||||
widget.field.readOnly = false;
|
widget.field.readOnly = false;
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
|
||||||
|
|
||||||
expect(widget.field.isValid).toBeFalsy();
|
expect(widget.field.isValid).toBeFalsy();
|
||||||
});
|
});
|
||||||
@ -231,22 +223,17 @@ describe('DateWidgetComponent', () => {
|
|||||||
field.isVisible = true;
|
field.isVisible = true;
|
||||||
field.dateDisplayFormat = 'MM-DD-YYYY';
|
field.dateDisplayFormat = 'MM-DD-YYYY';
|
||||||
widget.field = field;
|
widget.field = field;
|
||||||
widget.ngOnInit();
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
fixture.whenStable()
|
|
||||||
.then(() => {
|
|
||||||
expect(element.querySelector('#date-field-id')).toBeDefined();
|
|
||||||
expect(element.querySelector('#date-field-id')).not.toBeNull();
|
|
||||||
const dateElement: any = element.querySelector('#date-field-id');
|
|
||||||
expect(dateElement.value).toContain('12-30-9999');
|
|
||||||
|
|
||||||
widget.field.value = '03-02-2020';
|
expect(element.querySelector('#date-field-id')).toBeDefined();
|
||||||
|
expect(element.querySelector('#date-field-id')).not.toBeNull();
|
||||||
|
|
||||||
fixture.detectChanges();
|
const dateElement: any = element.querySelector('#date-field-id');
|
||||||
fixture.whenStable()
|
expect(dateElement.value).toContain('12-30-9999');
|
||||||
.then(() => {
|
|
||||||
expect(dateElement.value).toContain('03-02-2020');
|
widget.field.value = '03-02-2020';
|
||||||
});
|
|
||||||
});
|
fixture.detectChanges();
|
||||||
|
expect(dateElement.value).toContain('03-02-2020');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -149,10 +149,11 @@ describe('PeopleWidgetComponent', () => {
|
|||||||
widget.ngOnInit();
|
widget.ngOnInit();
|
||||||
|
|
||||||
const involvedUser = fixture.debugElement.nativeElement.querySelector('input[data-automation-id="adf-people-search-input"]');
|
const involvedUser = fixture.debugElement.nativeElement.querySelector('input[data-automation-id="adf-people-search-input"]');
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
fixture.whenStable().then(() => {
|
await fixture.whenStable();
|
||||||
expect(involvedUser.value).toBe('John Doe');
|
|
||||||
});
|
expect(involvedUser.value).toBe('John Doe');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when is required', () => {
|
describe('when is required', () => {
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { FormFieldTypes } from '../core/form-field-types';
|
import { FormFieldTypes } from '../core/form-field-types';
|
||||||
import { FormFieldModel } from '../core/form-field.model';
|
import { FormFieldModel } from '../core/form-field.model';
|
||||||
import { FormModel } from '../core/form.model';
|
import { FormModel } from '../core/form.model';
|
||||||
@ -248,14 +248,14 @@ describe('TextWidgetComponent', () => {
|
|||||||
inputElement = element.querySelector<HTMLInputElement>('#text-id');
|
inputElement = element.querySelector<HTMLInputElement>('#text-id');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be disabled on readonly forms', fakeAsync(() => {
|
it('should be disabled on readonly forms', async () => {
|
||||||
fixture.whenStable().then(() => {
|
await fixture.whenStable();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(inputElement).toBeDefined();
|
|
||||||
expect(inputElement).not.toBeNull();
|
expect(inputElement).toBeDefined();
|
||||||
expect(inputElement.disabled).toBeTruthy();
|
expect(inputElement).not.toBeNull();
|
||||||
});
|
expect(inputElement.disabled).toBeTruthy();
|
||||||
}));
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
|
||||||
import { FormFieldModel } from './core/form-field.model';
|
import { FormFieldModel } from './core/form-field.model';
|
||||||
import { FormModel } from './core/form.model';
|
import { FormModel } from './core/form.model';
|
||||||
import { WidgetComponent } from './widget.component';
|
import { WidgetComponent } from './widget.component';
|
||||||
@ -48,19 +48,21 @@ describe('WidgetComponent', () => {
|
|||||||
|
|
||||||
describe('Events', () => {
|
describe('Events', () => {
|
||||||
|
|
||||||
it('should click event be redirect on the form event service', async() => {
|
it('should click event be redirect on the form event service', fakeAsync(() => {
|
||||||
await widget.formService.formEvents.subscribe(() => {
|
widget.formService.formEvents.subscribe((event) => {
|
||||||
|
expect(event).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
element.click();
|
element.click();
|
||||||
});
|
}));
|
||||||
|
|
||||||
it('should click event be redirect on the form rules event service', async() => {
|
it('should click event be redirect on the form rules event service', fakeAsync(() => {
|
||||||
await widget.formService.formRulesEvent.pipe(filter(event => event.type === 'click')).subscribe(() => {
|
widget.formService.formRulesEvent.pipe(filter(event => event.type === 'click')).subscribe((event) => {
|
||||||
|
expect(event).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
element.click();
|
element.click();
|
||||||
});
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should check field', () => {
|
it('should check field', () => {
|
||||||
@ -69,7 +71,7 @@ describe('WidgetComponent', () => {
|
|||||||
expect(widget.hasField()).toBeTruthy();
|
expect(widget.hasField()).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should send an event after view init', async() => {
|
it('should send an event after view init', async () => {
|
||||||
const fakeForm = new FormModel();
|
const fakeForm = new FormModel();
|
||||||
const fakeField = new FormFieldModel(fakeForm, { id: 'fakeField', value: 'fakeValue' });
|
const fakeField = new FormFieldModel(fakeForm, { id: 'fakeField', value: 'fakeValue' });
|
||||||
widget.field = fakeField;
|
widget.field = fakeField;
|
||||||
@ -83,7 +85,7 @@ describe('WidgetComponent', () => {
|
|||||||
widget.ngAfterViewInit();
|
widget.ngAfterViewInit();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should send an event when a field is changed', async() => {
|
it('should send an event when a field is changed', async () => {
|
||||||
const fakeForm = new FormModel();
|
const fakeForm = new FormModel();
|
||||||
const fakeField = new FormFieldModel(fakeForm, { id: 'fakeField', value: 'fakeValue' });
|
const fakeField = new FormFieldModel(fakeForm, { id: 'fakeField', value: 'fakeValue' });
|
||||||
await widget.fieldChanged.subscribe((field) => {
|
await widget.fieldChanged.subscribe((field) => {
|
||||||
@ -95,7 +97,7 @@ describe('WidgetComponent', () => {
|
|||||||
widget.onFieldChanged(fakeField);
|
widget.onFieldChanged(fakeField);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should send a rule event when a field is changed', async() => {
|
it('should send a rule event when a field is changed', async () => {
|
||||||
const fakeForm = new FormModel();
|
const fakeForm = new FormModel();
|
||||||
const fakeField = new FormFieldModel(fakeForm, { id: 'fakeField', value: 'fakeValue' });
|
const fakeField = new FormFieldModel(fakeForm, { id: 'fakeField', value: 'fakeValue' });
|
||||||
await widget.formService.formRulesEvent.subscribe((event) => {
|
await widget.formService.formRulesEvent.subscribe((event) => {
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { TestBed } from '@angular/core/testing';
|
import { fakeAsync, TestBed } from '@angular/core/testing';
|
||||||
import { formModelTabs } from '../../mock';
|
import { formModelTabs } from '../../mock';
|
||||||
import { FormService } from './form.service';
|
import { FormService } from './form.service';
|
||||||
import { setupTestBed } from '../../testing/setup-test-bed';
|
import { setupTestBed } from '../../testing/setup-test-bed';
|
||||||
@ -352,7 +352,7 @@ describe('Form service', () => {
|
|||||||
expect(formParsed).toBeDefined();
|
expect(formParsed).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create a Form form a Node', async() => {
|
it('should create a Form form a Node', fakeAsync(() => {
|
||||||
const nameForm = 'testNode';
|
const nameForm = 'testNode';
|
||||||
const formId = 100;
|
const formId = 100;
|
||||||
|
|
||||||
@ -403,9 +403,9 @@ describe('Form service', () => {
|
|||||||
stubGetEcmModel();
|
stubGetEcmModel();
|
||||||
stubAddFieldsToAForm();
|
stubAddFieldsToAForm();
|
||||||
|
|
||||||
await service.createFormFromANode(nameForm).subscribe((result) => {
|
service.createFormFromANode(nameForm).subscribe((result) => {
|
||||||
expect(result.id).toEqual(formId);
|
expect(result.id).toEqual(formId);
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { TestBed } from '@angular/core/testing';
|
import { fakeAsync, TestBed } from '@angular/core/testing';
|
||||||
import {
|
import {
|
||||||
ContainerModel,
|
ContainerModel,
|
||||||
FormFieldModel,
|
FormFieldModel,
|
||||||
@ -298,16 +298,16 @@ describe('WidgetVisibilityCloudService', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should catch error on 403 response', (done) => {
|
it('should catch error on 403 response', fakeAsync(() => {
|
||||||
service.getTaskProcessVariable('9999').subscribe(() => {
|
service.getTaskProcessVariable('9999').subscribe(() => {
|
||||||
}, () => {
|
}, (errorMessage) => {
|
||||||
done();
|
expect(errorMessage).toEqual('Error while performing a call - Server error');
|
||||||
});
|
});
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
status: 403
|
status: 403
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('should return the value of the field', () => {
|
describe('should return the value of the field', () => {
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { TestBed } from '@angular/core/testing';
|
import { fakeAsync, TestBed } from '@angular/core/testing';
|
||||||
import {
|
import {
|
||||||
ContainerModel,
|
ContainerModel,
|
||||||
FormFieldModel,
|
FormFieldModel,
|
||||||
@ -301,16 +301,16 @@ describe('WidgetVisibilityService', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should catch error on 403 response', (done) => {
|
it('should catch error on 403 response', fakeAsync(() => {
|
||||||
service.getTaskProcessVariable('9999').subscribe(() => {
|
service.getTaskProcessVariable('9999').subscribe(() => {
|
||||||
}, () => {
|
}, (errorMessage) => {
|
||||||
done();
|
expect(errorMessage).toEqual('Error while performing a call - Server error');
|
||||||
});
|
});
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
status: 403
|
status: 403
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('should return the value of the field', () => {
|
describe('should return the value of the field', () => {
|
||||||
|
@ -118,18 +118,19 @@ describe('Custom SidebarActionMenuComponent', () => {
|
|||||||
expect(title.textContent).toBe('FakeTitle');
|
expect(title.textContent).toBe('FakeTitle');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render the adf-sidebar-menu-options', () => {
|
it('should render the adf-sidebar-menu-options', async () => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const actionButton = fixture.nativeElement.querySelector('.adf-sidebar-action-menu-button');
|
const actionButton = fixture.nativeElement.querySelector('.adf-sidebar-action-menu-button');
|
||||||
const options = fixture.nativeElement.querySelectorAll('.adf-sidebar-action-menu-options');
|
const options = fixture.nativeElement.querySelectorAll('.adf-sidebar-action-menu-options');
|
||||||
actionButton.click();
|
actionButton.click();
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
fixture.whenStable().then(() => {
|
await fixture.whenStable();
|
||||||
expect(actionButton).not.toBeNull();
|
|
||||||
expect(actionButton).toBeDefined();
|
expect(actionButton).not.toBeNull();
|
||||||
expect(options).toBeDefined();
|
expect(actionButton).toBeDefined();
|
||||||
expect(actionButton.innerText.trim()).toBe('Fake titlearrow_drop_down');
|
expect(options).toBeDefined();
|
||||||
});
|
expect(actionButton.innerText.trim()).toBe('Fake titlearrow_drop_down');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show icon on icon menu', () => {
|
it('should show icon on icon menu', () => {
|
||||||
|
@ -30,7 +30,6 @@ import { AlfrescoApiService } from '../../services/alfresco-api.service';
|
|||||||
|
|
||||||
import { setupTestBed } from '../../testing/setup-test-bed';
|
import { setupTestBed } from '../../testing/setup-test-bed';
|
||||||
import { CoreTestingModule } from '../../testing/core.testing.module';
|
import { CoreTestingModule } from '../../testing/core.testing.module';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
|
||||||
|
|
||||||
describe('LoginComponent', () => {
|
describe('LoginComponent', () => {
|
||||||
let component: LoginComponent;
|
let component: LoginComponent;
|
||||||
@ -60,7 +59,6 @@ describe('LoginComponent', () => {
|
|||||||
|
|
||||||
setupTestBed({
|
setupTestBed({
|
||||||
imports: [
|
imports: [
|
||||||
TranslateModule.forRoot(),
|
|
||||||
CoreTestingModule
|
CoreTestingModule
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@ -173,7 +171,7 @@ describe('LoginComponent', () => {
|
|||||||
expect(router.navigateByUrl).toHaveBeenCalledWith('some-route');
|
expect(router.navigateByUrl).toHaveBeenCalledWith('some-route');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should update user preferences upon login', fakeAsync(() => {
|
it('should update user preferences upon login', async () => {
|
||||||
spyOn(userPreferences, 'setStoragePrefix').and.callThrough();
|
spyOn(userPreferences, 'setStoragePrefix').and.callThrough();
|
||||||
spyOn(alfrescoApiService.getInstance(), 'login').and.returnValue(Promise.resolve());
|
spyOn(alfrescoApiService.getInstance(), 'login').and.returnValue(Promise.resolve());
|
||||||
|
|
||||||
@ -182,7 +180,9 @@ describe('LoginComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
loginWithCredentials('fake-username', 'fake-password');
|
loginWithCredentials('fake-username', 'fake-password');
|
||||||
}));
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
});
|
||||||
|
|
||||||
describe('Login button', () => {
|
describe('Login button', () => {
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { TestBed } from '@angular/core/testing';
|
import { fakeAsync, TestBed } from '@angular/core/testing';
|
||||||
import { AlfrescoApiService } from './alfresco-api.service';
|
import { AlfrescoApiService } from './alfresco-api.service';
|
||||||
import { AuthenticationService } from './authentication.service';
|
import { AuthenticationService } from './authentication.service';
|
||||||
import { CookieService } from './cookie.service';
|
import { CookieService } from './cookie.service';
|
||||||
@ -82,6 +82,8 @@ describe('AuthenticationService', () => {
|
|||||||
|
|
||||||
describe('when the setting is ECM', () => {
|
describe('when the setting is ECM', () => {
|
||||||
|
|
||||||
|
const fakeECMLoginResponse = { type: 'ECM', ticket: 'fake-post-ticket' };
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
appConfigService.config.providers = 'ECM';
|
appConfigService.config.providers = 'ECM';
|
||||||
appConfigService.load();
|
appConfigService.load();
|
||||||
@ -131,10 +133,10 @@ describe('AuthenticationService', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('[ECM] should login in the ECM if no provider are defined calling the login', (done) => {
|
it('[ECM] should login in the ECM if no provider are defined calling the login', fakeAsync(() => {
|
||||||
const disposableLogin = authService.login('fake-username', 'fake-password').subscribe(() => {
|
const disposableLogin = authService.login('fake-username', 'fake-password').subscribe((loginResponse) => {
|
||||||
|
expect(loginResponse).toEqual(fakeECMLoginResponse);
|
||||||
disposableLogin.unsubscribe();
|
disposableLogin.unsubscribe();
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
@ -142,9 +144,9 @@ describe('AuthenticationService', () => {
|
|||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
responseText: JSON.stringify({ entry: { id: 'fake-post-ticket', userId: 'admin' } })
|
responseText: JSON.stringify({ entry: { id: 'fake-post-ticket', userId: 'admin' } })
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
|
|
||||||
it('[ECM] should return a ticket undefined after logout', (done) => {
|
it('[ECM] should return a ticket undefined after logout', fakeAsync(() => {
|
||||||
const disposableLogin = authService.login('fake-username', 'fake-password').subscribe(() => {
|
const disposableLogin = authService.login('fake-username', 'fake-password').subscribe(() => {
|
||||||
const disposableLogout = authService.logout().subscribe(() => {
|
const disposableLogout = authService.logout().subscribe(() => {
|
||||||
expect(authService.isLoggedIn()).toBe(false);
|
expect(authService.isLoggedIn()).toBe(false);
|
||||||
@ -152,7 +154,6 @@ describe('AuthenticationService', () => {
|
|||||||
expect(authService.isEcmLoggedIn()).toBe(false);
|
expect(authService.isEcmLoggedIn()).toBe(false);
|
||||||
disposableLogin.unsubscribe();
|
disposableLogin.unsubscribe();
|
||||||
disposableLogout.unsubscribe();
|
disposableLogout.unsubscribe();
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
@ -165,7 +166,7 @@ describe('AuthenticationService', () => {
|
|||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
responseText: JSON.stringify({ entry: { id: 'fake-post-ticket', userId: 'admin' } })
|
responseText: JSON.stringify({ entry: { id: 'fake-post-ticket', userId: 'admin' } })
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
|
|
||||||
it('[ECM] should return false if the user is not logged in', () => {
|
it('[ECM] should return false if the user is not logged in', () => {
|
||||||
expect(authService.isLoggedIn()).toBe(false);
|
expect(authService.isLoggedIn()).toBe(false);
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { TestBed } from '@angular/core/testing';
|
import { fakeAsync, TestBed } from '@angular/core/testing';
|
||||||
import { BpmUserModel } from '../models/bpm-user.model';
|
import { BpmUserModel } from '../models/bpm-user.model';
|
||||||
import { BpmUserService } from './bpm-user.service';
|
import { BpmUserService } from './bpm-user.service';
|
||||||
import { setupTestBed } from '../testing/setup-test-bed';
|
import { setupTestBed } from '../testing/setup-test-bed';
|
||||||
@ -76,15 +76,15 @@ describe('Bpm user service', () => {
|
|||||||
expect(path).toContain('/app/rest/admin/profile-picture');
|
expect(path).toContain('/app/rest/admin/profile-picture');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should catch errors on call for profile', (done) => {
|
it('should catch errors on call for profile', fakeAsync(() => {
|
||||||
service.getCurrentUserInfo().subscribe(() => {
|
service.getCurrentUserInfo().subscribe(() => {
|
||||||
}, () => {
|
}, (error) => {
|
||||||
done();
|
expect(error).toEqual({ error: new Error('Unsuccessful HTTP response') });
|
||||||
});
|
});
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
status: 403
|
status: 403
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -25,12 +25,12 @@ describe('DownloadService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Download blob', () => {
|
describe('Download blob', () => {
|
||||||
it('Should use native msSaveOrOpenBlob if the browser is IE', (done) => {
|
it('Should use native msSaveOrOpenBlob if the browser is IE', () => {
|
||||||
const navigatorAny: any = window.navigator;
|
const navigatorAny: any = window.navigator;
|
||||||
|
|
||||||
// eslint-disable-next-line no-underscore-dangle
|
// eslint-disable-next-line no-underscore-dangle
|
||||||
navigatorAny.__defineGetter__('msSaveOrOpenBlob', () => {
|
navigatorAny.__defineGetter__('msSaveOrOpenBlob', (result) => {
|
||||||
done();
|
expect(result).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
const blob = new Blob([''], { type: 'text/html' });
|
const blob = new Blob([''], { type: 'text/html' });
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
import { HttpClientModule } from '@angular/common/http';
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
|
||||||
import { AppConfigService } from '../app-config/app-config.service';
|
import { AppConfigService } from '../app-config/app-config.service';
|
||||||
import { LogService } from './log.service';
|
import { LogService } from './log.service';
|
||||||
import { setupTestBed } from '../testing/setup-test-bed';
|
import { setupTestBed } from '../testing/setup-test-bed';
|
||||||
@ -165,15 +165,15 @@ describe('LogService', () => {
|
|||||||
expect(console.error).toHaveBeenCalled();
|
expect(console.error).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('message Observable', done => {
|
it('message Observable', fakeAsync(() => {
|
||||||
appConfigService.config['logLevel'] = 'trace';
|
appConfigService.config['logLevel'] = 'trace';
|
||||||
|
|
||||||
providesLogComponent.componentInstance.logService.onMessage.subscribe(
|
providesLogComponent.componentInstance.logService.onMessage.subscribe(
|
||||||
() => {
|
(message) => {
|
||||||
done();
|
expect(message).toEqual({ text: 'Test message', type: 'LOG' });
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
providesLogComponent.componentInstance.log();
|
providesLogComponent.componentInstance.log();
|
||||||
});
|
}));
|
||||||
});
|
});
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { TestBed } from '@angular/core/testing';
|
import { fakeAsync, TestBed } from '@angular/core/testing';
|
||||||
import { UserProcessModel } from '../models';
|
import { UserProcessModel } from '../models';
|
||||||
import { PeopleProcessService } from './people-process.service';
|
import { PeopleProcessService } from './people-process.service';
|
||||||
import { setupTestBed } from '../testing/setup-test-bed';
|
import { setupTestBed } from '../testing/setup-test-bed';
|
||||||
@ -40,6 +40,8 @@ const secondInvolvedUser: UserProcessModel = new UserProcessModel({
|
|||||||
|
|
||||||
const fakeInvolveUserList: UserProcessModel[] = [firstInvolvedUser, secondInvolvedUser];
|
const fakeInvolveUserList: UserProcessModel[] = [firstInvolvedUser, secondInvolvedUser];
|
||||||
|
|
||||||
|
const errorResponse = { error: new Error('Unsuccessful HTTP response') };
|
||||||
|
|
||||||
describe('PeopleProcessService', () => {
|
describe('PeopleProcessService', () => {
|
||||||
|
|
||||||
let service: PeopleProcessService;
|
let service: PeopleProcessService;
|
||||||
@ -65,7 +67,7 @@ describe('PeopleProcessService', () => {
|
|||||||
jasmine.Ajax.uninstall();
|
jasmine.Ajax.uninstall();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to retrieve people to involve in the task', (done) => {
|
it('should be able to retrieve people to involve in the task', fakeAsync(() => {
|
||||||
service.getWorkflowUsers('fake-task-id', 'fake-filter').subscribe(
|
service.getWorkflowUsers('fake-task-id', 'fake-filter').subscribe(
|
||||||
(users: UserProcessModel[]) => {
|
(users: UserProcessModel[]) => {
|
||||||
expect(users).toBeDefined();
|
expect(users).toBeDefined();
|
||||||
@ -74,30 +76,30 @@ describe('PeopleProcessService', () => {
|
|||||||
expect(users[0].email).toEqual('fake-user1@fake.com');
|
expect(users[0].email).toEqual('fake-user1@fake.com');
|
||||||
expect(users[0].firstName).toEqual('fakeName1');
|
expect(users[0].firstName).toEqual('fakeName1');
|
||||||
expect(users[0].lastName).toEqual('fakeLast1');
|
expect(users[0].lastName).toEqual('fakeLast1');
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
status: 200,
|
status: 200,
|
||||||
contentType: 'json',
|
contentType: 'json',
|
||||||
responseText: {data: fakeInvolveUserList}
|
responseText: {data: fakeInvolveUserList}
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
|
|
||||||
it('should be able to get people images for people retrieved', (done) => {
|
it('should be able to get people images for people retrieved', fakeAsync(() => {
|
||||||
service.getWorkflowUsers('fake-task-id', 'fake-filter').subscribe(
|
service.getWorkflowUsers('fake-task-id', 'fake-filter').subscribe(
|
||||||
(users: UserProcessModel[]) => {
|
(users: UserProcessModel[]) => {
|
||||||
expect(users).toBeDefined();
|
expect(users).toBeDefined();
|
||||||
expect(users.length).toBe(2);
|
expect(users.length).toBe(2);
|
||||||
expect(service.getUserImage(users[0])).toContain('/users/' + users[0].id + '/picture');
|
expect(service.getUserImage(users[0])).toContain('/users/' + users[0].id + '/picture');
|
||||||
expect(service.getUserImage(users[1])).toContain('/users/' + users[1].id + '/picture');
|
expect(service.getUserImage(users[1])).toContain('/users/' + users[1].id + '/picture');
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
status: 200,
|
status: 200,
|
||||||
contentType: 'json',
|
contentType: 'json',
|
||||||
responseText: {data: fakeInvolveUserList}
|
responseText: {data: fakeInvolveUserList}
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
|
|
||||||
it('should return user image url', () => {
|
it('should return user image url', () => {
|
||||||
const url = service.getUserImage(firstInvolvedUser);
|
const url = service.getUserImage(firstInvolvedUser);
|
||||||
@ -105,75 +107,75 @@ describe('PeopleProcessService', () => {
|
|||||||
expect(url).toContain('/users/' + firstInvolvedUser.id + '/picture');
|
expect(url).toContain('/users/' + firstInvolvedUser.id + '/picture');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return empty list when there are no users to involve', (done) => {
|
it('should return empty list when there are no users to involve', fakeAsync(() => {
|
||||||
service.getWorkflowUsers('fake-task-id', 'fake-filter').subscribe(
|
service.getWorkflowUsers('fake-task-id', 'fake-filter').subscribe(
|
||||||
(users: UserProcessModel[]) => {
|
(users: UserProcessModel[]) => {
|
||||||
expect(users).toBeDefined();
|
expect(users).toBeDefined();
|
||||||
expect(users.length).toBe(0);
|
expect(users.length).toBe(0);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
status: 200,
|
status: 200,
|
||||||
contentType: 'json',
|
contentType: 'json',
|
||||||
responseText: {}
|
responseText: {}
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
|
|
||||||
it('getWorkflowUsers catch errors call', (done) => {
|
it('getWorkflowUsers catch errors call', fakeAsync(() => {
|
||||||
service.getWorkflowUsers('fake-task-id', 'fake-filter').subscribe(() => {
|
service.getWorkflowUsers('fake-task-id', 'fake-filter').subscribe(() => {
|
||||||
}, () => {
|
}, (error) => {
|
||||||
done();
|
expect(error).toEqual(errorResponse);
|
||||||
});
|
});
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
status: 403
|
status: 403
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
|
|
||||||
it('should be able to involve people in the task', (done) => {
|
it('should be able to involve people in the task', fakeAsync(() => {
|
||||||
service.involveUserWithTask('fake-task-id', 'fake-user-id').subscribe(
|
service.involveUserWithTask('fake-task-id', 'fake-user-id').subscribe(
|
||||||
() => {
|
() => {
|
||||||
expect(jasmine.Ajax.requests.mostRecent().method).toBe('PUT');
|
expect(jasmine.Ajax.requests.mostRecent().method).toBe('PUT');
|
||||||
expect(jasmine.Ajax.requests.mostRecent().url).toContain('tasks/fake-task-id/action/involve');
|
expect(jasmine.Ajax.requests.mostRecent().url).toContain('tasks/fake-task-id/action/involve');
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
status: 200
|
status: 200
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
|
|
||||||
it('involveUserWithTask catch errors call', (done) => {
|
it('involveUserWithTask catch errors call', fakeAsync(() => {
|
||||||
service.involveUserWithTask('fake-task-id', 'fake-user-id').subscribe(() => {
|
service.involveUserWithTask('fake-task-id', 'fake-user-id').subscribe(() => {
|
||||||
}, () => {
|
}, (error) => {
|
||||||
done();
|
expect(error).toEqual(errorResponse);
|
||||||
});
|
});
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
status: 403
|
status: 403
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
|
|
||||||
it('should be able to remove involved people from task', (done) => {
|
it('should be able to remove involved people from task', fakeAsync(() => {
|
||||||
service.removeInvolvedUser('fake-task-id', 'fake-user-id').subscribe(
|
service.removeInvolvedUser('fake-task-id', 'fake-user-id').subscribe(
|
||||||
() => {
|
() => {
|
||||||
expect(jasmine.Ajax.requests.mostRecent().method).toBe('PUT');
|
expect(jasmine.Ajax.requests.mostRecent().method).toBe('PUT');
|
||||||
expect(jasmine.Ajax.requests.mostRecent().url).toContain('tasks/fake-task-id/action/remove-involved');
|
expect(jasmine.Ajax.requests.mostRecent().url).toContain('tasks/fake-task-id/action/remove-involved');
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
status: 200
|
status: 200
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
|
|
||||||
it('removeInvolvedUser catch errors call', (done) => {
|
it('removeInvolvedUser catch errors call', fakeAsync(() => {
|
||||||
service.removeInvolvedUser('fake-task-id', 'fake-user-id').subscribe(() => {
|
service.removeInvolvedUser('fake-task-id', 'fake-user-id').subscribe(() => {
|
||||||
}, () => {
|
}, (error) => {
|
||||||
done();
|
expect(error).toEqual(errorResponse);
|
||||||
});
|
});
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
status: 403
|
status: 403
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { TestBed } from '@angular/core/testing';
|
import { fakeAsync, TestBed } from '@angular/core/testing';
|
||||||
import { fakeRendition, fakeRenditionCreated, fakeRenditionsList, fakeRenditionsListWithACreated } from '../mock/renditions-service.mock';
|
import { fakeRendition, fakeRenditionCreated, fakeRenditionsList, fakeRenditionsListWithACreated } from '../mock/renditions-service.mock';
|
||||||
import { RenditionsService } from './renditions.service';
|
import { RenditionsService } from './renditions.service';
|
||||||
import { setupTestBed } from '../testing/setup-test-bed';
|
import { setupTestBed } from '../testing/setup-test-bed';
|
||||||
@ -25,6 +25,8 @@ import { TranslateModule } from '@ngx-translate/core';
|
|||||||
|
|
||||||
declare let jasmine: any;
|
declare let jasmine: any;
|
||||||
|
|
||||||
|
const errorResponse = { error: new Error('Parser is unable to parse the response') };
|
||||||
|
|
||||||
describe('RenditionsService', () => {
|
describe('RenditionsService', () => {
|
||||||
let service: RenditionsService;
|
let service: RenditionsService;
|
||||||
|
|
||||||
@ -110,10 +112,10 @@ describe('RenditionsService', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Get rendition service should catch the error', (done) => {
|
it('Get rendition service should catch the error', fakeAsync(() => {
|
||||||
service.getRenditionsListByNodeId('fake-node-id').subscribe(() => {
|
service.getRenditionsListByNodeId('fake-node-id').subscribe(() => {
|
||||||
}, () => {
|
}, (error) => {
|
||||||
done();
|
expect(error).toEqual(errorResponse);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -122,7 +124,7 @@ describe('RenditionsService', () => {
|
|||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
responseText: 'error'
|
responseText: 'error'
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
|
|
||||||
it('isConversionPossible should return true if is possible convert', (done) => {
|
it('isConversionPossible should return true if is possible convert', (done) => {
|
||||||
service.isConversionPossible('fake-node-id', 'pdf').subscribe((res) => {
|
service.isConversionPossible('fake-node-id', 'pdf').subscribe((res) => {
|
||||||
|
@ -1162,20 +1162,20 @@ describe('ViewerComponent', () => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should raise an event when the shared link is invalid', (done) => {
|
it('should raise an event when the shared link is invalid', fakeAsync(() => {
|
||||||
spyOn(component['sharedLinksApi'], 'getSharedLink')
|
spyOn(component['sharedLinksApi'], 'getSharedLink')
|
||||||
.and.returnValue(Promise.reject({}));
|
.and.returnValue(Promise.reject({}));
|
||||||
|
|
||||||
component.invalidSharedLink.subscribe(() => {
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
component.sharedLinkId = 'the-Shared-Link-id';
|
component.sharedLinkId = 'the-Shared-Link-id';
|
||||||
component.urlFile = null;
|
component.urlFile = null;
|
||||||
component.mimeType = null;
|
component.mimeType = null;
|
||||||
|
|
||||||
|
component.invalidSharedLink.subscribe((emittedValue) => {
|
||||||
|
expect(emittedValue).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
component.ngOnChanges();
|
component.ngOnChanges();
|
||||||
});
|
}));
|
||||||
|
|
||||||
it('should swicth to the unkwown template if the type specific viewers throw an error', (done) => {
|
it('should swicth to the unkwown template if the type specific viewers throw an error', (done) => {
|
||||||
component.urlFile = 'fake-url-file.icns';
|
component.urlFile = 'fake-url-file.icns';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user