mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
#189 Fix upload test
This commit is contained in:
@@ -15,14 +15,71 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { UploadService } from '../services/upload.service';
|
||||
import { AlfrescoSettingsService } from 'ng2-alfresco-core/dist/ng2-alfresco-core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observer } from 'rxjs/Observer';
|
||||
import { FileModel } from '../models/file.model';
|
||||
|
||||
export class UploadServiceMock {
|
||||
|
||||
private _baseUrlPath: string = 'fakebaseurlpath';
|
||||
private _url: string = 'fakeurl';
|
||||
private _formFields: Object = {};
|
||||
|
||||
filesUpload$: Observable<any>;
|
||||
totalCompleted$: Observable<number>;
|
||||
|
||||
public setOptions(options: any): void {
|
||||
this._url = options._url || this._url;
|
||||
this._baseUrlPath = options.baseUrlPath || this._baseUrlPath;
|
||||
this._formFields = options.formFields != null ? options.formFields : this._formFields;
|
||||
}
|
||||
|
||||
addToQueue(files: any[]): FileModel[] {
|
||||
this.filesUpload$ = new Observable(observer => {
|
||||
observer.next(files);
|
||||
});
|
||||
return files;
|
||||
}
|
||||
|
||||
createFolder(relativePath: string, name: string) {
|
||||
let promise: Promise<any>;
|
||||
if (name !== 'folder-duplicate-fake') {
|
||||
promise = new Promise(function (resolve, reject) {
|
||||
resolve({
|
||||
entry: {
|
||||
userId: 'fake-username',
|
||||
id: 'fake-post-token'
|
||||
}
|
||||
})
|
||||
});
|
||||
} else {
|
||||
promise = new Promise(function (resolve, reject) {
|
||||
reject({
|
||||
response: {
|
||||
body: {
|
||||
error: {
|
||||
statusCode: 409
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
return Observable.fromPromise(promise)
|
||||
.map(res => {
|
||||
return res;
|
||||
})
|
||||
.do(data => console.log('Node data', data))
|
||||
.catch((error => {
|
||||
return Observable.throw(error);
|
||||
}));
|
||||
}
|
||||
|
||||
public uploadFilesInTheQueue(directory: string, elementEmit: any): void {
|
||||
};
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user