Skip to content

Commit 29ff559

Browse files
[DSC-1864] fix test and lint
1 parent 9bf7207 commit 29ff559

61 files changed

Lines changed: 548 additions & 822 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/app/app.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { distinctUntilChanged, take, withLatestFrom, delay } from 'rxjs/operators';
2-
import { DOCUMENT, isPlatformBrowser } from '@angular/common';
2+
import { DOCUMENT } from '@angular/common';
33
import {
44
AfterViewInit,
55
ChangeDetectionStrategy,

src/app/browse-by/browse-by-date-page/browse-by-date-page.component.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { AppConfig, APP_CONFIG } from '../../../config/app-config.interface';
1919
import { RemoteData } from '../../core/data/remote-data';
2020
import { Item } from '../../core/shared/item.model';
2121
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
22-
import { SearchManager } from '../../core/browse/search-manager';
2322

2423
@Component({
2524
selector: 'ds-browse-by-date-page',
@@ -40,15 +39,14 @@ export class BrowseByDatePageComponent extends BrowseByMetadataPageComponent {
4039

4140
public constructor(protected route: ActivatedRoute,
4241
protected browseService: BrowseService,
43-
protected searchManager: SearchManager,
4442
protected dsoService: DSpaceObjectDataService,
4543
protected router: Router,
4644
protected paginationService: PaginationService,
4745
protected cdRef: ChangeDetectorRef,
4846
@Inject(APP_CONFIG) public appConfig: AppConfig,
4947
public dsoNameService: DSONameService,
5048
) {
51-
super(route, browseService, searchManager,dsoService, paginationService, router, appConfig, dsoNameService);
49+
super(route, browseService, dsoService, paginationService, router, appConfig, dsoNameService);
5250
}
5351

5452
ngOnInit(): void {

src/app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component.spec.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ import { PaginationService } from '../../core/pagination/pagination.service';
3030
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
3131
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
3232
import { APP_CONFIG } from '../../../config/app-config.interface';
33-
import { SearchManager } from '../../core/browse/search-manager';
3433
import { cold } from 'jasmine-marbles';
3534

36-
3735
describe('BrowseByMetadataPageComponent', () => {
3836
let comp: BrowseByMetadataPageComponent;
3937
let fixture: ComponentFixture<BrowseByMetadataPageComponent>;
@@ -90,13 +88,9 @@ describe('BrowseByMetadataPageComponent', () => {
9088

9189
const mockBrowseService = {
9290
getBrowseEntriesFor: (options: BrowseEntrySearchOptions) => toRemoteData(mockEntries),
91+
getBrowseItemsFor: (value: string, options: BrowseEntrySearchOptions) => toRemoteData(mockItems)
9392
};
9493

95-
const mockBrowseManager = {
96-
getBrowseItemsFor: () => toRemoteData(mockItems),
97-
};
98-
99-
10094
const mockDsoService = {
10195
findById: () => createSuccessfulRemoteDataObject$(mockCommunity)
10296
};
@@ -114,7 +108,6 @@ describe('BrowseByMetadataPageComponent', () => {
114108
providers: [
115109
{ provide: ActivatedRoute, useValue: activatedRouteStub },
116110
{ provide: BrowseService, useValue: mockBrowseService },
117-
{ provide: SearchManager, useValue: mockBrowseManager},
118111
{ provide: DSpaceObjectDataService, useValue: mockDsoService },
119112
{ provide: PaginationService, useValue: paginationService },
120113
{ provide: Router, useValue: new RouterMock() },

src/app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component.ts

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import { Collection } from '../../core/shared/collection.model';
2222
import { Community } from '../../core/shared/community.model';
2323
import { APP_CONFIG, AppConfig } from '../../../config/app-config.interface';
2424
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
25-
import { SearchManager } from '../../core/browse/search-manager';
2625

2726
export const BBM_PAGINATION_ID = 'bbm';
2827

@@ -109,8 +108,8 @@ export class BrowseByMetadataPageComponent implements OnInit, OnDestroy {
109108
value = '';
110109

111110
/**
112-
* The authority key (may be undefined) associated with {@link #value}.
113-
*/
111+
* The authority key (may be undefined) associated with {@link #value}.
112+
*/
114113
authority: string;
115114

116115
/**
@@ -130,7 +129,6 @@ export class BrowseByMetadataPageComponent implements OnInit, OnDestroy {
130129

131130
public constructor(protected route: ActivatedRoute,
132131
protected browseService: BrowseService,
133-
protected searchManager: SearchManager,
134132
protected dsoService: DSpaceObjectDataService,
135133
protected paginationService: PaginationService,
136134
protected router: Router,
@@ -140,11 +138,11 @@ export class BrowseByMetadataPageComponent implements OnInit, OnDestroy {
140138

141139
this.fetchThumbnails = this.appConfig.browseBy.showThumbnails;
142140
this.paginationConfig = Object.assign(new PaginationComponentOptions(), {
143-
id: BBM_PAGINATION_ID,
144-
currentPage: 1,
145-
pageSize: this.appConfig.browseBy.pageSize,
146-
});
147-
}
141+
id: BBM_PAGINATION_ID,
142+
currentPage: 1,
143+
pageSize: this.appConfig.browseBy.pageSize,
144+
});
145+
}
148146

149147

150148
ngOnInit(): void {
@@ -159,32 +157,32 @@ export class BrowseByMetadataPageComponent implements OnInit, OnDestroy {
159157
return [Object.assign({}, routeParams, queryParams),currentPage,currentSort];
160158
})
161159
).subscribe(([params, currentPage, currentSort]: [Params, PaginationComponentOptions, SortOptions]) => {
162-
this.browseId = params.id || this.defaultBrowseId;
163-
this.authority = +params.authority || params.authority || '';
160+
this.browseId = params.id || this.defaultBrowseId;
161+
this.authority = params.authority;
164162

165-
if (typeof params.value === 'string'){
166-
this.value = params.value.trim();
167-
} else {
168-
this.value = '';
169-
}
163+
if (typeof params.value === 'string'){
164+
this.value = params.value.trim();
165+
} else {
166+
this.value = '';
167+
}
170168

171-
if (params.startsWith === undefined || params.startsWith === '') {
172-
this.startsWith = undefined;
173-
}
169+
if (params.startsWith === undefined || params.startsWith === '') {
170+
this.startsWith = undefined;
171+
}
174172

175173
if (typeof params.startsWith === 'string'){
176-
this.startsWith = params.startsWith.trim();
177-
}
178-
179-
if (isNotEmpty(this.value) || isNotEmpty(this.authority)) {
180-
this.updatePageWithItems(
181-
browseParamsToOptions(params, currentPage, currentSort, this.browseId, this.fetchThumbnails), this.value, this.authority);
182-
} else {
183-
this.updatePage(browseParamsToOptions(params, currentPage, currentSort, this.browseId, false));
184-
}
185-
this.updateParent(params.scope);
186-
this.updateLogo();
187-
}));
174+
this.startsWith = params.startsWith.trim();
175+
}
176+
177+
if (isNotEmpty(this.value)) {
178+
this.updatePageWithItems(
179+
browseParamsToOptions(params, currentPage, currentSort, this.browseId, this.fetchThumbnails), this.value, this.authority);
180+
} else {
181+
this.updatePage(browseParamsToOptions(params, currentPage, currentSort, this.browseId, false));
182+
}
183+
this.updateParent(params.scope);
184+
this.updateLogo();
185+
}));
188186
this.updateStartsWithTextOptions();
189187

190188
}

src/app/browse-by/browse-by-title-page/browse-by-title-page.component.spec.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { PaginationService } from '../../core/pagination/pagination.service';
2222
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
2323
import { APP_CONFIG } from '../../../config/app-config.interface';
2424
import { environment } from '../../../environments/environment';
25-
import { SearchManager } from '../../core/browse/search-manager';
25+
2626

2727
describe('BrowseByTitlePageComponent', () => {
2828
let comp: BrowseByTitlePageComponent;
@@ -53,10 +53,6 @@ describe('BrowseByTitlePageComponent', () => {
5353
];
5454

5555
const mockBrowseService = {
56-
getBrowseEntriesFor: () => toRemoteData([])
57-
};
58-
59-
const mockBrowseManager = {
6056
getBrowseItemsFor: () => toRemoteData(mockItems),
6157
getBrowseEntriesFor: () => toRemoteData([])
6258
};
@@ -79,7 +75,6 @@ describe('BrowseByTitlePageComponent', () => {
7975
providers: [
8076
{ provide: ActivatedRoute, useValue: activatedRouteStub },
8177
{ provide: BrowseService, useValue: mockBrowseService },
82-
{ provide: SearchManager, useValue: mockBrowseManager },
8378
{ provide: DSpaceObjectDataService, useValue: mockDsoService },
8479
{ provide: PaginationService, useValue: paginationService },
8580
{ provide: Router, useValue: new RouterMock() },

src/app/browse-by/browse-by-title-page/browse-by-title-page.component.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { map } from 'rxjs/operators';
1414
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
1515
import { AppConfig, APP_CONFIG } from '../../../config/app-config.interface';
1616
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
17-
import { SearchManager } from '../../core/browse/search-manager';
1817

1918
@Component({
2019
selector: 'ds-browse-by-title-page',
@@ -28,14 +27,13 @@ export class BrowseByTitlePageComponent extends BrowseByMetadataPageComponent {
2827

2928
public constructor(protected route: ActivatedRoute,
3029
protected browseService: BrowseService,
31-
protected searchManager: SearchManager,
3230
protected dsoService: DSpaceObjectDataService,
3331
protected paginationService: PaginationService,
3432
protected router: Router,
3533
@Inject(APP_CONFIG) public appConfig: AppConfig,
3634
public dsoNameService: DSONameService,
3735
) {
38-
super(route, browseService, searchManager, dsoService, paginationService, router, appConfig, dsoNameService);
36+
super(route, browseService, dsoService, paginationService, router, appConfig, dsoNameService);
3937
}
4038

4139
ngOnInit(): void {

src/app/collection-page/collection-page-routing.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { ThemedCollectionPageComponent } from './themed-collection-page.componen
2323
import { MenuItemType } from '../shared/menu/menu-item-type.model';
2424
import { DSOEditMenuResolver } from '../shared/dso-page/dso-edit-menu.resolver';
2525
import { CommunityBreadcrumbResolver } from '../core/breadcrumbs/community-breadcrumb.resolver';
26-
import { EditCollectionResolver } from "../core/shared/resolvers/edit-collection.resolver";
26+
import { EditCollectionResolver } from '../core/shared/resolvers/edit-collection.resolver';
2727

2828
@NgModule({
2929
imports: [

src/app/core/browse/search-manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class SearchManager {
4343
* @param linksToFollow The array of [[FollowLinkConfig]]
4444
* @returns {Observable<RemoteData<PaginatedList<Item>>>}
4545
*/
46-
getBrowseItemsFor(filterValue: string, filterAuthority: string, options: BrowseEntrySearchOptions, ...linksToFollow: FollowLinkConfig<any>[]): Observable<RemoteData<PaginatedList<Item>>> {
46+
getBrowseItemsFor(filterValue: string, filterAuthority: string, options: BrowseEntrySearchOptions): Observable<RemoteData<PaginatedList<Item>>> {
4747
return this.browseService.getBrowseItemsFor(filterValue, filterAuthority, options)
4848
.pipe(this.completeWithExtraData());
4949
}

src/app/core/browse/search.manager.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ describe('SearchManager', () => {
127127
const options: BrowseEntrySearchOptions = { options: null} as any;
128128
const followLink: FollowLinkConfig<any> = {} as any;
129129

130-
scheduler.schedule(() => service.getBrowseItemsFor(filterValue, filterAuthority, options, followLink).subscribe());
130+
scheduler.schedule(() => service.getBrowseItemsFor(filterValue, filterAuthority, options).subscribe());
131131
scheduler.flush();
132132

133-
expect(mockBrowseService.getBrowseItemsFor).toHaveBeenCalledWith(filterValue, null, options, followLink);
133+
expect(mockBrowseService.getBrowseItemsFor).toHaveBeenCalledWith(filterValue, null, options);
134134
expect(mockItemService.findAllById).toHaveBeenCalledWith([validAuthority, validAuthority2]);
135135

136136
});
@@ -142,10 +142,10 @@ describe('SearchManager', () => {
142142
const options: BrowseEntrySearchOptions = { options: null} as any;
143143
const followLink: FollowLinkConfig<any> = {} as any;
144144

145-
scheduler.schedule(() => service.getBrowseItemsFor(filterValue, filterAuthority, options, followLink).subscribe());
145+
scheduler.schedule(() => service.getBrowseItemsFor(filterValue, filterAuthority, options).subscribe());
146146
scheduler.flush();
147147

148-
expect(mockBrowseService.getBrowseItemsFor).toHaveBeenCalledWith(filterValue, filterAuthority, options, followLink);
148+
expect(mockBrowseService.getBrowseItemsFor).toHaveBeenCalledWith(filterValue, filterAuthority, options);
149149
expect(mockItemService.findAllById).toHaveBeenCalledWith([validAuthority, validAuthority2]);
150150

151151
});

src/app/core/data/request.effects.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Injectable, Injector } from '@angular/core';
22

33
import { Actions, createEffect, ofType } from '@ngrx/effects';
4-
import { catchError, filter, map, mergeMap, take, withLatestFrom } from 'rxjs/operators';
4+
import { catchError, filter, map, mergeMap, take } from 'rxjs/operators';
55

66
import { hasValue, isNotEmpty } from '../../shared/empty.util';
77
import { StoreActionTypes } from '../../store.actions';
@@ -20,7 +20,6 @@ import {
2020
import { RequestService } from './request.service';
2121
import { ParsedResponse } from '../cache/response.models';
2222
import { RequestError } from './request-error.model';
23-
import { RestRequestMethod } from './rest-request-method';
2423
import { RestRequestWithResponseParser } from './rest-request-with-response-parser.model';
2524
import { RequestEntry } from './request-entry.model';
2625

0 commit comments

Comments
 (0)