feat(aio): improve search results functionality
* Ensure that all indexed documents are displayed in the search results. (Previously the guide documents were not appearing because we only showed results that had a `name` property, rather than a `name` or `title`.) * Group the results by their containing folder (e.g. api, guide, tutorial, etc). * Hide the results when the user hits the ESC key. * Hide the results when the user clicks on a search result Closes #14852
This commit is contained in:

committed by
Chuck Jazdzewski

parent
8850098ea4
commit
6497633529
@ -3,6 +3,7 @@ import { APP_BASE_HREF } from '@angular/common';
|
||||
import { AppComponent } from './app.component';
|
||||
import { AppModule } from './app.module';
|
||||
import { SearchService } from 'app/search/search.service';
|
||||
import { MockSearchService } from 'testing/search.service';
|
||||
|
||||
describe('AppComponent', () => {
|
||||
let component: AppComponent;
|
||||
@ -12,7 +13,8 @@ describe('AppComponent', () => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ AppModule ],
|
||||
providers: [
|
||||
{ provide: APP_BASE_HREF, useValue: '/' }
|
||||
{ provide: APP_BASE_HREF, useValue: '/' },
|
||||
{ provide: SearchService, useClass: MockSearchService }
|
||||
]
|
||||
});
|
||||
TestBed.compileComponents();
|
||||
@ -39,25 +41,19 @@ describe('AppComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('onSearch', () => {
|
||||
it('should call the search service', inject([SearchService], (search: SearchService) => {
|
||||
spyOn(search, 'search');
|
||||
component.onSearch('some query');
|
||||
expect(search.search).toHaveBeenCalledWith('some query');
|
||||
}));
|
||||
});
|
||||
|
||||
describe('currentDocument', () => {
|
||||
|
||||
console.log('PENDING: AppComponent currentDocument');
|
||||
});
|
||||
|
||||
describe('navigationViews', () => {
|
||||
|
||||
console.log('PENDING: AppComponent navigationViews');
|
||||
});
|
||||
|
||||
describe('searchResults', () => {
|
||||
|
||||
describe('initialisation', () => {
|
||||
it('should initialize the search worker', inject([SearchService], (searchService: SearchService) => {
|
||||
fixture.detectChanges(); // triggers ngOnInit
|
||||
expect(searchService.initWorker).toHaveBeenCalled();
|
||||
expect(searchService.loadIndex).toHaveBeenCalled();
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user