1- import { SearchService } from '../../../core/shared/search/search.service' ;
21import { ComponentFixture , TestBed , waitForAsync } from '@angular/core/testing' ;
32import { SearchSettingsComponent } from './search-settings.component' ;
43import { of as observableOf } from 'rxjs' ;
54import { PaginationComponentOptions } from '../../pagination/pagination-component-options.model' ;
65import { SortDirection , SortOptions } from '../../../core/cache/models/sort-options.model' ;
76import { TranslateModule } from '@ngx-translate/core' ;
87import { RouterTestingModule } from '@angular/router/testing' ;
9- import { ActivatedRoute } from '@angular/router' ;
108import { NO_ERRORS_SCHEMA } from '@angular/core' ;
119import { EnumKeysPipe } from '../../utils/enum-keys-pipe' ;
1210import { By } from '@angular/platform-browser' ;
13- import { SearchFilterService } from '../../../core/shared/search/search-filter.service' ;
1411import { VarDirective } from '../../utils/var.directive' ;
1512import { SEARCH_CONFIG_SERVICE } from '../../../my-dspace-page/my-dspace-page.component' ;
16- import { SidebarService } from '../../sidebar/sidebar.service' ;
17- import { SidebarServiceStub } from '../../testing/sidebar-service.stub' ;
1813import { PaginationService } from '../../../core/pagination/pagination.service' ;
1914import { PaginationServiceStub } from '../../testing/pagination-service.stub' ;
2015
2116describe ( 'SearchSettingsComponent' , ( ) => {
2217
2318 let comp : SearchSettingsComponent ;
2419 let fixture : ComponentFixture < SearchSettingsComponent > ;
25- let searchServiceObject : SearchService ;
2620
2721 let pagination : PaginationComponentOptions ;
2822 let sort : SortOptions ;
29- let mockResults ;
30- let searchServiceStub ;
3123
3224 let queryParam ;
3325 let scopeParam ;
3426 let paginatedSearchOptions ;
3527
36- let paginationService ;
28+ let paginationService : PaginationServiceStub ;
3729
38- let activatedRouteStub ;
3930
40- beforeEach ( waitForAsync ( ( ) => {
31+ beforeEach ( waitForAsync ( async ( ) => {
4132 pagination = new PaginationComponentOptions ( ) ;
4233 pagination . id = 'search-results-pagination' ;
4334 pagination . currentPage = 1 ;
4435 pagination . pageSize = 10 ;
4536 sort = new SortOptions ( 'score' , SortDirection . DESC ) ;
46- mockResults = [ 'test' , 'data' ] ;
47- searchServiceStub = {
48- searchOptions : { pagination : pagination , sort : sort } ,
49- search : ( ) => mockResults ,
50- } ;
5137
5238 queryParam = 'test query' ;
5339 scopeParam = '7669c72a-3f2a-451f-a3b9-9210e7a4c02f' ;
@@ -58,30 +44,12 @@ describe('SearchSettingsComponent', () => {
5844 sort,
5945 } ;
6046
61- activatedRouteStub = {
62- queryParams : observableOf ( {
63- query : queryParam ,
64- scope : scopeParam ,
65- } ) ,
66- } ;
67-
6847 paginationService = new PaginationServiceStub ( pagination , sort ) ;
6948
70- TestBed . configureTestingModule ( {
49+ await TestBed . configureTestingModule ( {
7150 imports : [ TranslateModule . forRoot ( ) , RouterTestingModule . withRoutes ( [ ] ) ] ,
7251 declarations : [ SearchSettingsComponent , EnumKeysPipe , VarDirective ] ,
7352 providers : [
74- { provide : SearchService , useValue : searchServiceStub } ,
75-
76- { provide : ActivatedRoute , useValue : activatedRouteStub } ,
77- {
78- provide : SidebarService ,
79- useValue : SidebarServiceStub ,
80- } ,
81- {
82- provide : SearchFilterService ,
83- useValue : { } ,
84- } ,
8553 {
8654 provide : PaginationService ,
8755 useValue : paginationService ,
@@ -111,10 +79,7 @@ describe('SearchSettingsComponent', () => {
11179
11280 // SearchPageComponent test instance
11381 fixture . detectChanges ( ) ;
114- searchServiceObject = ( comp as any ) . service ;
11582 spyOn ( comp , 'reloadOrder' ) ;
116- spyOn ( searchServiceObject , 'search' ) . and . callThrough ( ) ;
117-
11883 } ) ;
11984
12085 it ( 'it should show the order settings with the respective selectable options' , ( ) => {
0 commit comments