[ADF-2070][ADF-2071][ADF-2072] 'Load more' on destination picker does… (#2774)

* [ADF-2070][ADF-2071][ADF-2072] 'Load more' on destination picker doesn't display correct content of folders

* [ADF-2070][ADF-2071][ADF-2072] add tests

* [ADF-2070][ADF-2071][ADF-2072] 'Load more' on destination picker doesn't display correct content of folders
This commit is contained in:
suzanadirla
2017-12-20 00:14:36 +02:00
committed by Eugenio Romano
parent 413dcc9e45
commit 553ae4db7b
2 changed files with 32 additions and 1 deletions

View File

@@ -522,6 +522,34 @@ describe('ContentNodeSelectorComponent', () => {
expect(searchSpy).toHaveBeenCalledWith(defaultSearchOptions('kakarot', undefined, skipCount));
});
it('should be shown when pagination\'s hasMoreItems is true', () => {
component.pagination = {
hasMoreItems: true
};
fixture.detectChanges();
const pagination = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-pagination"]'));
expect(pagination).not.toBeNull();
});
it('button\'s callback should load the next batch of folder results when there is no searchTerm', () => {
const skipCount = 5;
component.searchTerm = '';
component.pagination = {
hasMoreItems: true
};
fixture.detectChanges();
component.getNextPageOfSearch({skipCount});
fixture.detectChanges();
expect(component.searchTerm).toBe('');
expect(component.infiniteScroll).toBeTruthy();
expect(component.skipCount).toBe(skipCount);
expect(searchSpy).not.toHaveBeenCalled();
});
it('should set its loading state to true after search was started', (done) => {
component.showingSearchResults = true;
component.pagination = { hasMoreItems: true };

View File

@@ -202,8 +202,11 @@ export class ContentNodeSelectorPanelComponent implements OnInit {
getNextPageOfSearch(event: Pagination): void {
this.infiniteScroll = true;
this.skipCount = event.skipCount;
if (this.searchTerm.length > 0) {
this.querySearch();
}
}
/**
* Perform the call to searchService with the proper parameters