feat(aio): display “Searching ..." while building search index

closes #15923
This commit is contained in:
Ward Bell 2017-06-21 13:17:12 -07:00 committed by Hans
parent 97fd2480e7
commit 34cc3f2982
3 changed files with 9 additions and 1 deletions

View File

@ -24,5 +24,5 @@
</ng-template> </ng-template>
<ng-template #notFound> <ng-template #notFound>
<p>No results found.</p> <p>{{notFoundMessage}}</p>
</ng-template> </ng-template>

View File

@ -129,6 +129,11 @@ describe('SearchResultsComponent', () => {
expect(component.searchAreas).toEqual([]); expect(component.searchAreas).toEqual([]);
}); });
it('should display "Searching ..." while waiting for search results', () => {
fixture.detectChanges();
expect(getText()).toContain('Searching ...');
});
describe('when a search result anchor is clicked', () => { describe('when a search result anchor is clicked', () => {
let searchResult: SearchResult; let searchResult: SearchResult;
let selected: SearchResult; let selected: SearchResult;
@ -179,4 +184,5 @@ describe('SearchResultsComponent', () => {
expect(getText()).toContain('No results'); expect(getText()).toContain('No results');
}); });
}); });
}); });

View File

@ -21,6 +21,7 @@ export class SearchResultsComponent implements OnInit, OnDestroy {
private resultsSubscription: Subscription; private resultsSubscription: Subscription;
readonly defaultArea = 'other'; readonly defaultArea = 'other';
notFoundMessage = 'Searching ...';
readonly topLevelFolders = ['guide', 'tutorial']; readonly topLevelFolders = ['guide', 'tutorial'];
/** /**
@ -54,6 +55,7 @@ export class SearchResultsComponent implements OnInit, OnDestroy {
// Map the search results into groups by area // Map the search results into groups by area
private processSearchResults(search: SearchResults) { private processSearchResults(search: SearchResults) {
this.notFoundMessage = 'No results found.';
const searchAreaMap = {}; const searchAreaMap = {};
search.results.forEach(result => { search.results.forEach(result => {
if (!result.title) { return; } // bad data; should fix if (!result.title) { return; } // bad data; should fix