[ADF-2391] skipCount is not reset on document-list when choosing a custom source from adf-sites-dropdown, nor the currentFolderId and folderNode (#3012)

* [ADF-2391] skipCount is not reset on document-list when choosing a custom source from adf-sites-dropdown, nor the currentFolderId and folderNode

fix and tests added

* [ADF-2391] refactor code & took into account merge parameter
This commit is contained in:
suzanadirla
2018-03-06 11:58:28 +02:00
committed by Eugenio Romano
parent f41498658b
commit 0a748ac555
2 changed files with 58 additions and 0 deletions

View File

@@ -1218,6 +1218,27 @@ describe('DocumentList', () => {
expect(documentList.folderNode).toBeNull();
});
it('should reset folder node on loading folder by node id', () => {
documentList.folderNode = <any> {};
const sitesApi = apiService.getInstance().core.sitesApi;
spyOn(sitesApi, 'getSites').and.returnValue(Promise.resolve(null));
documentList.loadFolderByNodeId('-sites-');
expect(documentList.folderNode).toBeNull();
});
it('should have correct currentFolderId on loading folder by node id', () => {
documentList.currentFolderId = '12345-some-id-6789';
const peopleApi = apiService.getInstance().core.peopleApi;
spyOn(peopleApi, 'getSiteMembership').and.returnValue(Promise.resolve());
documentList.loadFolderByNodeId('-mysites-');
expect(documentList.currentFolderId).toBe('-mysites-');
});
it('should update pagination settings', () => {
spyOn(documentList, 'reload').and.stub();
@@ -1304,4 +1325,21 @@ describe('DocumentList', () => {
expect(documentList.reload).toHaveBeenCalled();
});
it('should reset skipCount from pagination settings on loading folder by node id', () => {
spyOn(documentList, 'reload').and.stub();
const favoritesApi = apiService.getInstance().core.favoritesApi;
spyOn(favoritesApi, 'getFavorites').and.returnValue(Promise.resolve(null));
documentList.maxItems = 0;
documentList.skipCount = 0;
documentList.updatePagination({
maxItems: 10,
skipCount: 10
});
documentList.loadFolderByNodeId('-favorites-');
expect(documentList.skipCount).toBe(0, 'skipCount is reset');
});
});