[ADF-3864] Create library - no error is displayed when name contains white spaces only (#4101)

* only spaces error message

* title custom error support

* tests

* validate title against only spaces

* generate id only when title is valid
This commit is contained in:
Cilibiu Bogdan
2018-12-21 20:06:35 +02:00
committed by Eugenio Romano
parent b035193be5
commit 7f106f7a56
4 changed files with 78 additions and 9 deletions

View File

@@ -214,4 +214,46 @@ describe('LibraryDialogComponent', () => {
message: 'LIBRARY.ERRORS.CONFLICT'
});
}));
it('should not translate library title if value is not a valid id', fakeAsync(() => {
spyOn(alfrescoApi.sitesApi, 'getSite').and.callFake(() => {
return new Promise((resolve, reject) => reject());
});
fixture.detectChanges();
component.form.controls.title.setValue('@@@####');
tick(500);
flush();
fixture.detectChanges();
expect(component.form.controls.id.value).toBe(null);
}));
it('should translate library title partially for library id', fakeAsync(() => {
spyOn(alfrescoApi.sitesApi, 'getSite').and.callFake(() => {
return new Promise((resolve, reject) => reject());
});
fixture.detectChanges();
component.form.controls.title.setValue('@@@####library');
tick(500);
flush();
fixture.detectChanges();
expect(component.form.controls.id.value).toBe('library');
}));
it('should translate library title multiple space character to one dash for library id', fakeAsync(() => {
spyOn(alfrescoApi.sitesApi, 'getSite').and.callFake(() => {
return new Promise((resolve, reject) => reject());
});
fixture.detectChanges();
component.form.controls.title.setValue('library title');
tick(500);
flush();
fixture.detectChanges();
expect(component.form.controls.id.value).toBe('library-title');
}));
});