[CSTPER-3620] Workflow Actions refresh entire MyDSpace page instead of just WorkflowItem

Task Service implementation.
ReloadableAction abstraction.
This commit is contained in:
Alessandro Martelli
2020-12-18 12:19:09 +01:00
parent e867badcb5
commit e32c86f127
56 changed files with 1489 additions and 287 deletions

View File

@@ -4,7 +4,7 @@ import { TestScheduler } from 'rxjs/testing';
import { getMockRequestService } from '../../shared/mocks/request.service.mock';
import { TasksService } from './tasks.service';
import { RequestService } from '../data/request.service';
import { TaskDeleteRequest, TaskPostRequest } from '../data/request.models';
import { FindListOptions, TaskDeleteRequest, TaskPostRequest } from '../data/request.models';
import { HALEndpointService } from '../shared/hal-endpoint.service';
import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub';
import { TaskObject } from './models/task-object.model';
@@ -17,8 +17,8 @@ import { HttpClient, HttpHeaders } from '@angular/common/http';
import { DSOChangeAnalyzer } from '../data/dso-change-analyzer.service';
import { ChangeAnalyzer } from '../data/change-analyzer';
import { compare, Operation } from 'fast-json-patch';
import { of as observableOf } from 'rxjs/internal/observable/of';
import { HttpOptions } from '../dspace-rest/dspace-rest.service';
import { getMockRemoteDataBuildService } from '../../shared/mocks/remote-data-build.service.mock';
const LINK_NAME = 'test';
@@ -57,7 +57,7 @@ describe('TasksService', () => {
const linkPath = 'testTask';
const requestService = getMockRequestService();
const halService: any = new HALEndpointServiceStub(taskEndpoint);
const rdbService = getMockRemoteDataBuildService();
const rdbService = {} as RemoteDataBuildService;
const notificationsService = {} as NotificationsService;
const http = {} as HttpClient;
const comparator = new DummyChangeAnalyzer() as any;
@@ -117,4 +117,38 @@ describe('TasksService', () => {
});
});
describe('searchTask', () => {
it('should call findByHref with the href generated by getSearchByHref', () => {
spyOn(service, 'getSearchByHref').and.returnValue(observableOf('generatedHref'));
spyOn(service, 'findByHref').and.returnValue(null);
const followLinks = {};
const options = new FindListOptions();
options.searchParams = [];
scheduler.schedule(() => service.searchTask('method', options, followLinks as any).subscribe());
scheduler.flush();
expect(service.getSearchByHref).toHaveBeenCalledWith('method', options, followLinks as any);
expect(service.findByHref).toHaveBeenCalledWith('generatedHref');
});
});
describe('getEndpointById', () => {
it('should call halService.getEndpoint and then getEndpointByIDHref', () => {
spyOn(halService, 'getEndpoint').and.returnValue(observableOf('generatedHref'));
spyOn(service, 'getEndpointByIDHref').and.returnValue(null);
scheduler.schedule(() => service.getEndpointById('scopeId').subscribe());
scheduler.flush();
expect(halService.getEndpoint).toHaveBeenCalledWith(service.getLinkPath());
expect(service.getEndpointByIDHref).toHaveBeenCalledWith('generatedHref', 'scopeId');
});
});
});