[ASD-2483] Validate folder name on change (#3088)

* notify service refactoring
get translate eliminitation in favor of instant
add error event where necessary
fix config problem during test

* fix delete notify test

* remove fdescribe

* fix core test

* errors

* fix types
This commit is contained in:
Eugenio Romano
2018-03-21 16:55:52 +00:00
committed by GitHub
parent de0fdd9ab4
commit 2951374cc0
25 changed files with 357 additions and 260 deletions

View File

@@ -20,6 +20,7 @@ import { FileModel, LogService, UploadService } from '@alfresco/adf-core';
import { FileDraggableDirective } from '../directives/file-draggable.directive';
import { UploadDragAreaComponent } from './upload-drag-area.component';
import { Observable } from 'rxjs/Observable';
function getFakeShareDataRow(allowableOperations = ['delete', 'update', 'create']) {
return {
@@ -95,7 +96,7 @@ describe('UploadDragAreaComponent', () => {
spyOn(uploadService, 'uploadFilesInTheQueue');
fixture.detectChanges();
const file = <File> {name: 'fake-name-1', size: 10, webkitRelativePath: 'fake-folder1/fake-name-1.json'};
const file = <File> { name: 'fake-name-1', size: 10, webkitRelativePath: 'fake-folder1/fake-name-1.json' };
let filesList = [file];
component.onFilesDropped(filesList);
@@ -115,7 +116,7 @@ describe('UploadDragAreaComponent', () => {
isFile: true,
name: 'file-fake.png',
file: (callbackFile) => {
let fileFake = new File(['fakefake'], 'file-fake.png', {type: 'image/png'});
let fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
callbackFile(fileFake);
}
};
@@ -161,7 +162,7 @@ describe('UploadDragAreaComponent', () => {
isFile: true,
name: 'file-fake.png',
file: (callbackFile) => {
let fileFake = new File(['fakefake'], 'file-fake.png', {type: 'image/png'});
let fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
callbackFile(fileFake);
}
};
@@ -182,7 +183,7 @@ describe('UploadDragAreaComponent', () => {
uploadService.uploadFilesInTheQueue = jasmine.createSpy('uploadFilesInTheQueue');
fixture.detectChanges();
const file = <File> {name: 'fake-name-1', size: 10, webkitRelativePath: 'fake-folder1/fake-name-1.json'};
const file = <File> { name: 'fake-name-1', size: 10, webkitRelativePath: 'fake-folder1/fake-name-1.json' };
let filesList = [file];
spyOn(uploadService, 'addToQueue').and.callFake((f: FileModel) => {
@@ -205,7 +206,7 @@ describe('UploadDragAreaComponent', () => {
isFile: true,
name: 'file-fake.png',
file: (callbackFile) => {
let fileFake = new File(['fakefake'], 'file-fake.png', {type: 'image/png'});
let fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
callbackFile(fileFake);
}
};
@@ -226,7 +227,7 @@ describe('UploadDragAreaComponent', () => {
isFile: true,
name: 'file-fake.png',
file: (callbackFile) => {
let fileFake = new File(['fakefake'], 'file-fake.png', {type: 'image/png'});
let fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
callbackFile(fileFake);
}
};
@@ -242,7 +243,7 @@ describe('UploadDragAreaComponent', () => {
isFile: true,
name: 'file-fake.png',
file: (callbackFile) => {
let fileFake = new File(['fakefake'], 'file-fake.png', {type: 'image/png'});
let fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
callbackFile(fileFake);
}
};
@@ -262,4 +263,36 @@ describe('UploadDragAreaComponent', () => {
component.onUploadFiles(fakeCustomEvent);
}));
describe('Events', () => {
it('should raise an error if upload a file goes wrong', (done) => {
let fakeItem = {
fullPath: '/folder-fake/file-fake.png',
isDirectory: false,
isFile: true,
name: 'file-fake.png',
file: (callbackFile) => {
let fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
callbackFile(fileFake);
}
};
fixture.detectChanges();
spyOn(uploadService, 'fileUploadError').and.returnValue(Observable.throw(new Error()));
component.error.subscribe((error) => {
expect(error).not.toBeNull();
done();
});
let fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
detail: {
data: getFakeShareDataRow(),
files: [fakeItem]
}
});
component.onUploadFiles(fakeCustomEvent);
});
});
});