mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 15:03:07 +00:00
93803: Ensure data services are called *DataService
This commit is contained in:
77
src/app/core/data/external-source-data.service.spec.ts
Normal file
77
src/app/core/data/external-source-data.service.spec.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
import { ExternalSourceDataService } from './external-source-data.service';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
|
||||
import { createPaginatedList } from '../../shared/testing/utils.test';
|
||||
import { ExternalSourceEntry } from '../shared/external-source-entry.model';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { GetRequest } from './request.models';
|
||||
|
||||
describe('ExternalSourceService', () => {
|
||||
let service: ExternalSourceDataService;
|
||||
|
||||
let requestService;
|
||||
let rdbService;
|
||||
let halService;
|
||||
|
||||
const entries = [
|
||||
Object.assign(new ExternalSourceEntry(), {
|
||||
id: '0001-0001-0001-0001',
|
||||
display: 'John Doe',
|
||||
value: 'John, Doe',
|
||||
metadata: {
|
||||
'dc.identifier.uri': [
|
||||
{
|
||||
value: 'https://orcid.org/0001-0001-0001-0001'
|
||||
}
|
||||
]
|
||||
}
|
||||
}),
|
||||
Object.assign(new ExternalSourceEntry(), {
|
||||
id: '0001-0001-0001-0002',
|
||||
display: 'Sampson Megan',
|
||||
value: 'Sampson, Megan',
|
||||
metadata: {
|
||||
'dc.identifier.uri': [
|
||||
{
|
||||
value: 'https://orcid.org/0001-0001-0001-0002'
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
];
|
||||
|
||||
function init() {
|
||||
requestService = jasmine.createSpyObj('requestService', {
|
||||
generateRequestId: 'request-uuid',
|
||||
send: {}
|
||||
});
|
||||
rdbService = jasmine.createSpyObj('rdbService', {
|
||||
buildList: createSuccessfulRemoteDataObject$(createPaginatedList(entries))
|
||||
});
|
||||
halService = jasmine.createSpyObj('halService', {
|
||||
getEndpoint: observableOf('external-sources-REST-endpoint'),
|
||||
});
|
||||
service = new ExternalSourceDataService(requestService, rdbService, undefined, halService);
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
init();
|
||||
});
|
||||
|
||||
describe('getExternalSourceEntries', () => {
|
||||
let result;
|
||||
|
||||
beforeEach(() => {
|
||||
result = service.getExternalSourceEntries('test');
|
||||
});
|
||||
|
||||
it('should send a GetRequest', () => {
|
||||
expect(requestService.send).toHaveBeenCalledWith(jasmine.any(GetRequest), true);
|
||||
});
|
||||
|
||||
it('should return the entries', () => {
|
||||
result.subscribe((resultRD) => {
|
||||
expect(resultRD.payload.page).toBe(entries);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user