Skip to content

Commit 371e766

Browse files
Fixed tests without expectations from DSpace#2759 & DSpace#2681
Added the necessary done() calls back & fixed tests
1 parent 87788e7 commit 371e766

3 files changed

Lines changed: 15 additions & 21 deletions

File tree

src/app/core/coar-notify/notify-info/notify-info.service.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { TestBed } from '@angular/core/testing';
2-
32
import { NotifyInfoService } from './notify-info.service';
43
import { ConfigurationDataService } from '../../data/configuration-data.service';
54
import { of } from 'rxjs';
65
import { AuthorizationDataService } from '../../data/feature-authorization/authorization-data.service';
6+
import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
77

88
describe('NotifyInfoService', () => {
99
let service: NotifyInfoService;
@@ -32,21 +32,21 @@ describe('NotifyInfoService', () => {
3232
expect(service).toBeTruthy();
3333
});
3434

35-
it('should retrieve and map coar configuration', () => {
36-
const mockResponse = { payload: { values: ['true'] } };
37-
(configurationDataService.findByPropertyName as jasmine.Spy).and.returnValue(of(mockResponse));
35+
it('should retrieve and map coar configuration', (done: DoneFn) => {
36+
(configurationDataService.findByPropertyName as jasmine.Spy).and.returnValue(createSuccessfulRemoteDataObject$({ values: ['true'] }));
3837

3938
service.isCoarConfigEnabled().subscribe((result) => {
4039
expect(result).toBe(true);
40+
done();
4141
});
4242
});
4343

44-
it('should retrieve and map LDN local inbox URLs', () => {
45-
const mockResponse = { values: ['inbox1', 'inbox2'] };
46-
(configurationDataService.findByPropertyName as jasmine.Spy).and.returnValue(of(mockResponse));
44+
it('should retrieve and map LDN local inbox URLs', (done: DoneFn) => {
45+
(configurationDataService.findByPropertyName as jasmine.Spy).and.returnValue(createSuccessfulRemoteDataObject$({ values: ['inbox1', 'inbox2'] }));
4746

4847
service.getCoarLdnLocalInboxUrls().subscribe((result) => {
4948
expect(result).toEqual(['inbox1', 'inbox2']);
49+
done();
5050
});
5151
});
5252

src/app/shared/dso-page/dso-edit-menu.resolver.spec.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ import { Community } from '../../core/shared/community.model';
2424
import { Collection } from '../../core/shared/collection.model';
2525
import flatten from 'lodash/flatten';
2626
import { DsoWithdrawnReinstateModalService } from './dso-withdrawn-reinstate-service/dso-withdrawn-reinstate-modal.service';
27-
import { AuthService } from 'src/app/core/auth/auth.service';
28-
import { AuthServiceMock } from '../mocks/auth.service.mock';
2927
import { CorrectionTypeDataService } from 'src/app/core/submission/correctiontype-data.service';
28+
import { createPaginatedList } from '../testing/utils.test';
3029

3130
describe('DSOEditMenuResolver', () => {
3231

@@ -152,7 +151,7 @@ describe('DSOEditMenuResolver', () => {
152151
});
153152

154153
correctionsDataService = jasmine.createSpyObj('correctionsDataService', {
155-
findByItem: observableOf([])
154+
findByItem: createSuccessfulRemoteDataObject$(createPaginatedList([])),
156155
});
157156

158157
TestBed.configureTestingModule({
@@ -167,7 +166,6 @@ describe('DSOEditMenuResolver', () => {
167166
{provide: TranslateService, useValue: translate},
168167
{provide: NotificationsService, useValue: notificationsService},
169168
{provide: DsoWithdrawnReinstateModalService, useValue: dsoWithdrawnReinstateModalService},
170-
{provide: AuthService, useValue: new AuthServiceMock()},
171169
{provide: CorrectionTypeDataService, useValue: correctionsDataService},
172170
{
173171
provide: NgbModal, useValue: {
@@ -367,7 +365,7 @@ describe('DSOEditMenuResolver', () => {
367365
route = dsoRoute(testItem);
368366
});
369367

370-
it('should return Item-specific entries', () => {
368+
it('should return Item-specific entries', (done: DoneFn) => {
371369
const result = resolver.getDsoMenus(testObject, route, state);
372370
combineLatest(result).pipe(map(flatten)).subscribe((menu) => {
373371
const orcidEntry = menu.find(entry => entry.id === 'orcid-dso');
@@ -388,18 +386,20 @@ describe('DSOEditMenuResolver', () => {
388386
expect(claimEntry.active).toBeFalse();
389387
expect(claimEntry.visible).toBeFalse();
390388
expect(claimEntry.model.type).toEqual(MenuItemType.ONCLICK);
389+
done();
391390
});
392391
});
393392

394-
it('should not return Community/Collection-specific entries', () => {
393+
it('should not return Community/Collection-specific entries', (done: DoneFn) => {
395394
const result = resolver.getDsoMenus(testObject, route, state);
396395
combineLatest(result).pipe(map(flatten)).subscribe((menu) => {
397396
const subscribeEntry = menu.find(entry => entry.id === 'subscribe');
398397
expect(subscribeEntry).toBeFalsy();
398+
done();
399399
});
400400
});
401401

402-
it('should return as third part the common list ', () => {
402+
it('should return as third part the common list ', (done: DoneFn) => {
403403
const result = resolver.getDsoMenus(testObject, route, state);
404404
combineLatest(result).pipe(map(flatten)).subscribe((menu) => {
405405
const editEntry = menu.find(entry => entry.id === 'edit-dso');
@@ -410,6 +410,7 @@ describe('DSOEditMenuResolver', () => {
410410
expect((editEntry.model as LinkMenuItemModel).link).toEqual(
411411
'/items/test-item-uuid/edit/metadata'
412412
);
413+
done();
413414
});
414415
});
415416
});

src/app/shared/dso-page/dso-edit-menu.resolver.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ import { ResearcherProfileDataService } from '../../core/profile/researcher-prof
2424
import { NotificationsService } from '../notifications/notifications.service';
2525
import { TranslateService } from '@ngx-translate/core';
2626
import { DsoWithdrawnReinstateModalService, REQUEST_REINSTATE, REQUEST_WITHDRAWN } from './dso-withdrawn-reinstate-service/dso-withdrawn-reinstate-modal.service';
27-
import { AuthService } from '../../core/auth/auth.service';
28-
import { FindListOptions } from '../../core/data/find-list-options.model';
29-
import { RequestParam } from '../../core/cache/models/request-param.model';
3027
import { CorrectionTypeDataService } from '../../core/submission/correctiontype-data.service';
3128
import { SubscriptionModalComponent } from '../subscriptions/subscription-modal/subscription-modal.component';
3229
import { Community } from '../../core/shared/community.model';
@@ -50,7 +47,6 @@ export class DSOEditMenuResolver implements Resolve<{ [key: string]: MenuSection
5047
protected notificationsService: NotificationsService,
5148
protected translate: TranslateService,
5249
protected dsoWithdrawnReinstateModalService: DsoWithdrawnReinstateModalService,
53-
private auth: AuthService,
5450
private correctionTypeDataService: CorrectionTypeDataService
5551
) {
5652
}
@@ -133,9 +129,6 @@ export class DSOEditMenuResolver implements Resolve<{ [key: string]: MenuSection
133129
*/
134130
protected getItemMenu(dso): Observable<MenuSection[]> {
135131
if (dso instanceof Item) {
136-
const findListTopicOptions: FindListOptions = {
137-
searchParams: [new RequestParam('target', dso.uuid)]
138-
};
139132
return combineLatest([
140133
this.authorizationService.isAuthorized(FeatureID.CanCreateVersion, dso.self),
141134
this.dsoVersioningModalService.isNewVersionButtonDisabled(dso),

0 commit comments

Comments
 (0)