mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
emit errors (#2593)
This commit is contained in:
committed by
Eugenio Romano
parent
1a01b67e7c
commit
75b0267f0b
@@ -916,6 +916,17 @@ describe('DocumentList', () => {
|
||||
expect(apiService.nodesApi.getDeletedNodes).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should emit error when fetch trashcan fails', (done) => {
|
||||
spyOn(apiService.nodesApi, 'getDeletedNodes').and.returnValue(Promise.reject('error'));
|
||||
|
||||
documentList.error.subscribe(val => {
|
||||
expect(val).toBe('error');
|
||||
done();
|
||||
});
|
||||
|
||||
documentList.loadFolderByNodeId('-trashcan-');
|
||||
});
|
||||
|
||||
it('should fetch shared links', () => {
|
||||
const sharedlinksApi = apiService.getInstance().core.sharedlinksApi;
|
||||
spyOn(sharedlinksApi, 'findSharedLinks').and.returnValue(Promise.resolve(null));
|
||||
@@ -924,6 +935,18 @@ describe('DocumentList', () => {
|
||||
expect(sharedlinksApi.findSharedLinks).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should emit error when fetch shared links fails', (done) => {
|
||||
spyOn(apiService.getInstance().core.sharedlinksApi, 'findSharedLinks')
|
||||
.and.returnValue(Promise.reject('error'));
|
||||
|
||||
documentList.error.subscribe(val => {
|
||||
expect(val).toBe('error');
|
||||
done();
|
||||
});
|
||||
|
||||
documentList.loadFolderByNodeId('-sharedlinks-');
|
||||
});
|
||||
|
||||
it('should fetch sites', () => {
|
||||
const sitesApi = apiService.getInstance().core.sitesApi;
|
||||
spyOn(sitesApi, 'getSites').and.returnValue(Promise.resolve(null));
|
||||
@@ -932,6 +955,18 @@ describe('DocumentList', () => {
|
||||
expect(sitesApi.getSites).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should emit error when fetch sites fails', (done) => {
|
||||
spyOn(apiService.getInstance().core.sitesApi, 'getSites')
|
||||
.and.returnValue(Promise.reject('error'));
|
||||
|
||||
documentList.error.subscribe(val => {
|
||||
expect(val).toBe('error');
|
||||
done();
|
||||
});
|
||||
|
||||
documentList.loadFolderByNodeId('-sites-');
|
||||
});
|
||||
|
||||
it('should fetch user membership sites', () => {
|
||||
const peopleApi = apiService.getInstance().core.peopleApi;
|
||||
spyOn(peopleApi, 'getSiteMembership').and.returnValue(Promise.resolve());
|
||||
@@ -940,6 +975,18 @@ describe('DocumentList', () => {
|
||||
expect(peopleApi.getSiteMembership).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should emit error when fetch membership sites fails', (done) => {
|
||||
spyOn(apiService.getInstance().core.peopleApi, 'getSiteMembership')
|
||||
.and.returnValue(Promise.reject('error'));
|
||||
|
||||
documentList.error.subscribe(val => {
|
||||
expect(val).toBe('error');
|
||||
done();
|
||||
});
|
||||
|
||||
documentList.loadFolderByNodeId('-mysites-');
|
||||
});
|
||||
|
||||
it('should fetch favorites', () => {
|
||||
const favoritesApi = apiService.getInstance().core.favoritesApi;
|
||||
spyOn(favoritesApi, 'getFavorites').and.returnValue(Promise.resolve(null));
|
||||
@@ -948,6 +995,18 @@ describe('DocumentList', () => {
|
||||
expect(favoritesApi.getFavorites).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should emit error when fetch favorites fails', (done) => {
|
||||
spyOn(apiService.getInstance().core.favoritesApi, 'getFavorites')
|
||||
.and.returnValue(Promise.reject('error'));
|
||||
|
||||
documentList.error.subscribe(val => {
|
||||
expect(val).toBe('error');
|
||||
done();
|
||||
});
|
||||
|
||||
documentList.loadFolderByNodeId('-favorites-');
|
||||
});
|
||||
|
||||
it('should fetch recent', (done) => {
|
||||
const person = { entry: { id: 'person '} };
|
||||
|
||||
@@ -963,6 +1022,30 @@ describe('DocumentList', () => {
|
||||
}, 100);
|
||||
});
|
||||
|
||||
it('should emit error when fetch recent fails on getPerson call', (done) => {
|
||||
spyOn(apiService.peopleApi, 'getPerson').and.returnValue(Promise.reject('error'));
|
||||
|
||||
documentList.error.subscribe(val => {
|
||||
expect(val).toBe('error');
|
||||
done();
|
||||
});
|
||||
|
||||
documentList.loadFolderByNodeId('-recent-');
|
||||
});
|
||||
|
||||
it('should emit error when fetch recent fails on search call', (done) => {
|
||||
const person = { entry: { id: 'person '} };
|
||||
spyOn(apiService.peopleApi, 'getPerson').and.returnValue(Promise.resolve(person));
|
||||
spyOn(apiService.searchApi, 'search').and.returnValue(Promise.reject('error'));
|
||||
|
||||
documentList.error.subscribe(val => {
|
||||
expect(val).toBe('error');
|
||||
done();
|
||||
});
|
||||
|
||||
documentList.loadFolderByNodeId('-recent-');
|
||||
});
|
||||
|
||||
it('should switch to another page', () => {
|
||||
spyOn(documentList, 'reload').and.stub();
|
||||
|
||||
|
@@ -499,9 +499,9 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
|
||||
maxItems: this.pageSize,
|
||||
skipCount: this.skipCount
|
||||
};
|
||||
this.apiService.nodesApi.getDeletedNodes(options).then((page: DeletedNodesPaging) => {
|
||||
this.onPageLoaded(page);
|
||||
});
|
||||
this.apiService.nodesApi.getDeletedNodes(options)
|
||||
.then((page: DeletedNodesPaging) => this.onPageLoaded(page))
|
||||
.catch(error => this.error.emit(error));
|
||||
}
|
||||
|
||||
private loadSharedLinks(): void {
|
||||
@@ -510,9 +510,9 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
|
||||
maxItems: this.pageSize,
|
||||
skipCount: this.skipCount
|
||||
};
|
||||
this.apiService.sharedLinksApi.findSharedLinks(options).then((page: NodePaging) => {
|
||||
this.onPageLoaded(page);
|
||||
});
|
||||
this.apiService.sharedLinksApi.findSharedLinks(options)
|
||||
.then((page: NodePaging) => this.onPageLoaded(page))
|
||||
.catch(error => this.error.emit(error));
|
||||
}
|
||||
|
||||
private loadSites(): void {
|
||||
@@ -522,9 +522,9 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
|
||||
skipCount: this.skipCount
|
||||
};
|
||||
|
||||
this.apiService.sitesApi.getSites(options).then((page: NodePaging) => {
|
||||
this.onPageLoaded(page);
|
||||
});
|
||||
this.apiService.sitesApi.getSites(options)
|
||||
.then((page: NodePaging) => this.onPageLoaded(page))
|
||||
.catch(error => this.error.emit(error));
|
||||
}
|
||||
|
||||
private loadMemberSites(): void {
|
||||
@@ -534,7 +534,8 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
|
||||
skipCount: this.skipCount
|
||||
};
|
||||
|
||||
this.apiService.peopleApi.getSiteMembership('-me-', options).then((result: SitePaging) => {
|
||||
this.apiService.peopleApi.getSiteMembership('-me-', options)
|
||||
.then((result: SitePaging) => {
|
||||
let page: NodePaging = {
|
||||
list: {
|
||||
entries: result.list.entries
|
||||
@@ -546,7 +547,8 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
|
||||
};
|
||||
|
||||
this.onPageLoaded(page);
|
||||
});
|
||||
})
|
||||
.catch(error => this.error.emit(error));
|
||||
}
|
||||
|
||||
private loadFavorites(): void {
|
||||
@@ -557,7 +559,8 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
|
||||
include: [ 'properties', 'allowableOperations', 'path' ]
|
||||
};
|
||||
|
||||
this.apiService.favoritesApi.getFavorites('-me-', options).then((result: NodePaging) => {
|
||||
this.apiService.favoritesApi.getFavorites('-me-', options)
|
||||
.then((result: NodePaging) => {
|
||||
let page: NodePaging = {
|
||||
list: {
|
||||
entries: result.list.entries
|
||||
@@ -575,11 +578,13 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
|
||||
}
|
||||
};
|
||||
this.onPageLoaded(page);
|
||||
});
|
||||
})
|
||||
.catch(error => this.error.emit(error));
|
||||
}
|
||||
|
||||
private loadRecent(): void {
|
||||
this.apiService.peopleApi.getPerson('-me-').then((person: PersonEntry) => {
|
||||
this.apiService.peopleApi.getPerson('-me-')
|
||||
.then((person: PersonEntry) => {
|
||||
const username = person.entry.id;
|
||||
const query = {
|
||||
query: {
|
||||
@@ -603,8 +608,10 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
|
||||
}
|
||||
};
|
||||
|
||||
this.apiService.searchApi.search(query).then(page => this.onPageLoaded(page));
|
||||
});
|
||||
return this.apiService.searchApi.search(query);
|
||||
})
|
||||
.then((page: NodePaging) => this.onPageLoaded(page))
|
||||
.catch(error => this.error.emit(error));
|
||||
}
|
||||
|
||||
private onPageLoaded(page: NodePaging) {
|
||||
|
Reference in New Issue
Block a user