mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
fix lint, fix tests
This commit is contained in:
@@ -198,7 +198,7 @@ import { NotifyRequestsStatus } from '../item-page/simple/notify-requests-status
|
|||||||
import { LdnService } from '../admin/admin-ldn-services/ldn-services-model/ldn-services.model';
|
import { LdnService } from '../admin/admin-ldn-services/ldn-services-model/ldn-services.model';
|
||||||
import { Itemfilter } from '../admin/admin-ldn-services/ldn-services-model/ldn-service-itemfilters';
|
import { Itemfilter } from '../admin/admin-ldn-services/ldn-services-model/ldn-service-itemfilters';
|
||||||
import { SubmissionCoarNotifyConfig } from '../submission/sections/section-coar-notify/submission-coar-notify.config';
|
import { SubmissionCoarNotifyConfig } from '../submission/sections/section-coar-notify/submission-coar-notify.config';
|
||||||
import { AdminNotifyMessage } from "../admin/admin-notify-dashboard/models/admin-notify-message.model";
|
import { AdminNotifyMessage } from '../admin/admin-notify-dashboard/models/admin-notify-message.model';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When not in production, endpoint responses can be mocked for testing purposes
|
* When not in production, endpoint responses can be mocked for testing purposes
|
||||||
|
@@ -1,115 +0,0 @@
|
|||||||
import { TestScheduler } from 'rxjs/testing';
|
|
||||||
import { RequestService } from '../../../data/request.service';
|
|
||||||
import { RemoteDataBuildService } from '../../../cache/builders/remote-data-build.service';
|
|
||||||
import { ObjectCacheService } from '../../../cache/object-cache.service';
|
|
||||||
import { HALEndpointService } from '../../../shared/hal-endpoint.service';
|
|
||||||
import { RequestEntry } from '../../../data/request-entry.model';
|
|
||||||
import { cold, getTestScheduler } from 'jasmine-marbles';
|
|
||||||
import { RestResponse } from '../../../cache/response.models';
|
|
||||||
import { of as observableOf } from 'rxjs';
|
|
||||||
import { Store } from '@ngrx/store';
|
|
||||||
import { CoreState } from '../../../core-state.model';
|
|
||||||
import { HttpClient } from '@angular/common/http';
|
|
||||||
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
|
|
||||||
import { DefaultChangeAnalyzer } from '../../../data/default-change-analyzer.service';
|
|
||||||
import { testFindAllDataImplementation } from '../../../data/base/find-all-data.spec';
|
|
||||||
import { FindAllData } from '../../../data/base/find-all-data';
|
|
||||||
import { GetRequest } from '../../../data/request.models';
|
|
||||||
import {
|
|
||||||
createSuccessfulRemoteDataObject$
|
|
||||||
} from '../../../../shared/remote-data.utils';
|
|
||||||
import { RemoteData } from '../../../data/remote-data';
|
|
||||||
import { RequestEntryState } from '../../../data/request-entry-state.model';
|
|
||||||
import { SuggestionSourceDataService } from './suggestion-source-data.service';
|
|
||||||
import { SuggestionSource } from '../models/suggestion-source.model';
|
|
||||||
|
|
||||||
describe('SuggestionSourceDataService test', () => {
|
|
||||||
let scheduler: TestScheduler;
|
|
||||||
let service: SuggestionSourceDataService;
|
|
||||||
let requestService: RequestService;
|
|
||||||
let rdbService: RemoteDataBuildService;
|
|
||||||
let objectCache: ObjectCacheService;
|
|
||||||
let halService: HALEndpointService;
|
|
||||||
let notificationsService: NotificationsService;
|
|
||||||
let http: HttpClient;
|
|
||||||
let comparator: DefaultChangeAnalyzer<SuggestionSource>;
|
|
||||||
let responseCacheEntry: RequestEntry;
|
|
||||||
|
|
||||||
const store = {} as Store<CoreState>;
|
|
||||||
const endpointURL = `https://rest.api/rest/api/suggestionsources`;
|
|
||||||
const requestUUID = '8b3c613a-5a4b-438b-9686-be1d5b4a1c5a';
|
|
||||||
|
|
||||||
const remoteDataMocks = {
|
|
||||||
Success: new RemoteData(null, null, null, RequestEntryState.Success, null, null, 200),
|
|
||||||
};
|
|
||||||
|
|
||||||
function initTestService() {
|
|
||||||
return new SuggestionSourceDataService(
|
|
||||||
requestService,
|
|
||||||
rdbService,
|
|
||||||
store,
|
|
||||||
objectCache,
|
|
||||||
halService,
|
|
||||||
notificationsService,
|
|
||||||
http,
|
|
||||||
comparator
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
scheduler = getTestScheduler();
|
|
||||||
|
|
||||||
objectCache = {} as ObjectCacheService;
|
|
||||||
http = {} as HttpClient;
|
|
||||||
notificationsService = {} as NotificationsService;
|
|
||||||
comparator = {} as DefaultChangeAnalyzer<SuggestionSource>;
|
|
||||||
responseCacheEntry = new RequestEntry();
|
|
||||||
responseCacheEntry.request = { href: 'https://rest.api/' } as any;
|
|
||||||
responseCacheEntry.response = new RestResponse(true, 200, 'Success');
|
|
||||||
|
|
||||||
requestService = jasmine.createSpyObj('requestService', {
|
|
||||||
generateRequestId: requestUUID,
|
|
||||||
send: true,
|
|
||||||
removeByHrefSubstring: {},
|
|
||||||
getByHref: observableOf(responseCacheEntry),
|
|
||||||
getByUUID: observableOf(responseCacheEntry),
|
|
||||||
});
|
|
||||||
|
|
||||||
halService = jasmine.createSpyObj('halService', {
|
|
||||||
getEndpoint: observableOf(endpointURL)
|
|
||||||
});
|
|
||||||
|
|
||||||
rdbService = jasmine.createSpyObj('rdbService', {
|
|
||||||
buildSingle: createSuccessfulRemoteDataObject$({}, 500),
|
|
||||||
buildList: cold('a', { a: remoteDataMocks.Success })
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
service = initTestService();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('composition', () => {
|
|
||||||
const initFindAllService = () => new SuggestionSourceDataService(null, null, null, null, null, null, null, null) as unknown as FindAllData<any>;
|
|
||||||
testFindAllDataImplementation(initFindAllService);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getSources', () => {
|
|
||||||
it('should send a new GetRequest', () => {
|
|
||||||
const expected = new GetRequest(requestService.generateRequestId(), `${endpointURL}`);
|
|
||||||
scheduler.schedule(() => service.getSources().subscribe());
|
|
||||||
scheduler.flush();
|
|
||||||
|
|
||||||
expect(requestService.send).toHaveBeenCalledWith(expected, true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getSource', () => {
|
|
||||||
it('should send a new GetRequest', () => {
|
|
||||||
const expected = new GetRequest(requestService.generateRequestId(), `${endpointURL}/testId`);
|
|
||||||
scheduler.schedule(() => service.getSource('testId').subscribe());
|
|
||||||
scheduler.flush();
|
|
||||||
|
|
||||||
expect(requestService.send).toHaveBeenCalledWith(expected, true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@@ -1,173 +0,0 @@
|
|||||||
import { TestScheduler } from 'rxjs/testing';
|
|
||||||
import { SuggestionDataServiceImpl, SuggestionsDataService } from './suggestions-data.service';
|
|
||||||
import { RequestService } from '../../data/request.service';
|
|
||||||
import { RemoteDataBuildService } from '../../cache/builders/remote-data-build.service';
|
|
||||||
import { ObjectCacheService } from '../../cache/object-cache.service';
|
|
||||||
import { HALEndpointService } from '../../shared/hal-endpoint.service';
|
|
||||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
|
||||||
import { HttpClient } from '@angular/common/http';
|
|
||||||
import { DefaultChangeAnalyzer } from '../../data/default-change-analyzer.service';
|
|
||||||
import { Suggestion } from './models/suggestion.model';
|
|
||||||
import { cold, getTestScheduler } from 'jasmine-marbles';
|
|
||||||
import { RequestEntry } from '../../data/request-entry.model';
|
|
||||||
import { RestResponse } from '../../cache/response.models';
|
|
||||||
import { of as observableOf } from 'rxjs';
|
|
||||||
import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
|
|
||||||
import { RemoteData } from '../../data/remote-data';
|
|
||||||
import { RequestEntryState } from '../../data/request-entry-state.model';
|
|
||||||
import { SuggestionSource } from './models/suggestion-source.model';
|
|
||||||
import { SuggestionTarget } from './models/suggestion-target.model';
|
|
||||||
import { SuggestionSourceDataService } from './source/suggestion-source-data.service';
|
|
||||||
import { SuggestionTargetDataService } from './target/suggestion-target-data.service';
|
|
||||||
import { RequestParam } from '../../cache/models/request-param.model';
|
|
||||||
|
|
||||||
describe('SuggestionDataService test', () => {
|
|
||||||
let scheduler: TestScheduler;
|
|
||||||
let service: SuggestionsDataService;
|
|
||||||
let requestService: RequestService;
|
|
||||||
let rdbService: RemoteDataBuildService;
|
|
||||||
let objectCache: ObjectCacheService;
|
|
||||||
let halService: HALEndpointService;
|
|
||||||
let notificationsService: NotificationsService;
|
|
||||||
let http: HttpClient;
|
|
||||||
let comparatorSuggestion: DefaultChangeAnalyzer<Suggestion>;
|
|
||||||
let comparatorSuggestionSource: DefaultChangeAnalyzer<SuggestionSource>;
|
|
||||||
let comparatorSuggestionTarget: DefaultChangeAnalyzer<SuggestionTarget>;
|
|
||||||
let suggestionSourcesDataService: SuggestionSourceDataService;
|
|
||||||
let suggestionTargetsDataService: SuggestionTargetDataService;
|
|
||||||
let suggestionsDataService: SuggestionDataServiceImpl;
|
|
||||||
let responseCacheEntry: RequestEntry;
|
|
||||||
|
|
||||||
|
|
||||||
const testSource = 'test-source';
|
|
||||||
const testUserId = '1234-4321';
|
|
||||||
const endpointURL = `https://rest.api/rest/api/`;
|
|
||||||
const requestUUID = '8b3c613a-5a4b-438b-9686-be1d5b4a1c5a';
|
|
||||||
const remoteDataMocks = {
|
|
||||||
Success: new RemoteData(null, null, null, RequestEntryState.Success, null, null, 200),
|
|
||||||
};
|
|
||||||
|
|
||||||
function initTestService() {
|
|
||||||
return new SuggestionsDataService(
|
|
||||||
requestService,
|
|
||||||
rdbService,
|
|
||||||
objectCache,
|
|
||||||
halService,
|
|
||||||
notificationsService,
|
|
||||||
http,
|
|
||||||
comparatorSuggestion,
|
|
||||||
comparatorSuggestionSource,
|
|
||||||
comparatorSuggestionTarget
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
scheduler = getTestScheduler();
|
|
||||||
|
|
||||||
objectCache = {} as ObjectCacheService;
|
|
||||||
http = {} as HttpClient;
|
|
||||||
notificationsService = {} as NotificationsService;
|
|
||||||
comparatorSuggestion = {} as DefaultChangeAnalyzer<Suggestion>;
|
|
||||||
comparatorSuggestionTarget = {} as DefaultChangeAnalyzer<SuggestionTarget>;
|
|
||||||
comparatorSuggestionSource = {} as DefaultChangeAnalyzer<SuggestionSource>;
|
|
||||||
responseCacheEntry = new RequestEntry();
|
|
||||||
responseCacheEntry.request = { href: 'https://rest.api/' } as any;
|
|
||||||
responseCacheEntry.response = new RestResponse(true, 200, 'Success');
|
|
||||||
|
|
||||||
requestService = jasmine.createSpyObj('requestService', {
|
|
||||||
generateRequestId: requestUUID,
|
|
||||||
send: true,
|
|
||||||
removeByHrefSubstring: {},
|
|
||||||
getByHref: observableOf(responseCacheEntry),
|
|
||||||
getByUUID: observableOf(responseCacheEntry),
|
|
||||||
setStaleByHrefSubstring: observableOf(true)
|
|
||||||
});
|
|
||||||
|
|
||||||
halService = jasmine.createSpyObj('halService', {
|
|
||||||
getEndpoint: observableOf(endpointURL)
|
|
||||||
});
|
|
||||||
|
|
||||||
rdbService = jasmine.createSpyObj('rdbService', {
|
|
||||||
buildSingle: createSuccessfulRemoteDataObject$({}, 500),
|
|
||||||
buildList: cold('a', { a: remoteDataMocks.Success })
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
suggestionSourcesDataService = jasmine.createSpyObj('suggestionSourcesDataService', {
|
|
||||||
getSources: observableOf(null),
|
|
||||||
});
|
|
||||||
|
|
||||||
suggestionTargetsDataService = jasmine.createSpyObj('suggestionTargetsDataService', {
|
|
||||||
getTargets: observableOf(null),
|
|
||||||
getTargetsByUser: observableOf(null),
|
|
||||||
findById: observableOf(null),
|
|
||||||
});
|
|
||||||
|
|
||||||
suggestionsDataService = jasmine.createSpyObj('suggestionsDataService', {
|
|
||||||
searchBy: observableOf(null),
|
|
||||||
delete: observableOf(null),
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
service = initTestService();
|
|
||||||
/* eslint-disable-next-line @typescript-eslint/dot-notation */
|
|
||||||
service['suggestionSourcesDataService'] = suggestionSourcesDataService;
|
|
||||||
/* eslint-disable-next-line @typescript-eslint/dot-notation */
|
|
||||||
service['suggestionTargetsDataService'] = suggestionTargetsDataService;
|
|
||||||
/* eslint-disable-next-line @typescript-eslint/dot-notation */
|
|
||||||
service['suggestionsDataService'] = suggestionsDataService;
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Suggestion targets service', () => {
|
|
||||||
it('should call suggestionSourcesDataService.getTargets', () => {
|
|
||||||
const options = {
|
|
||||||
searchParams: [new RequestParam('source', testSource)]
|
|
||||||
};
|
|
||||||
service.getTargets(testSource);
|
|
||||||
expect(suggestionTargetsDataService.getTargets).toHaveBeenCalledWith('findBySource', options);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should call suggestionSourcesDataService.getTargetsByUser', () => {
|
|
||||||
const options = {
|
|
||||||
searchParams: [new RequestParam('target', testUserId)]
|
|
||||||
};
|
|
||||||
service.getTargetsByUser(testUserId);
|
|
||||||
expect(suggestionTargetsDataService.getTargetsByUser).toHaveBeenCalledWith(testUserId, options);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should call suggestionSourcesDataService.getTargetById', () => {
|
|
||||||
service.getTargetById('1');
|
|
||||||
expect(suggestionTargetsDataService.findById).toHaveBeenCalledWith('1');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
describe('Suggestion sources service', () => {
|
|
||||||
it('should call suggestionSourcesDataService.getSources', () => {
|
|
||||||
service.getSources();
|
|
||||||
expect(suggestionSourcesDataService.getSources).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Suggestion service', () => {
|
|
||||||
it('should call suggestionsDataService.searchBy', () => {
|
|
||||||
const options = {
|
|
||||||
searchParams: [new RequestParam('target', testUserId), new RequestParam('source', testSource)]
|
|
||||||
};
|
|
||||||
service.getSuggestionsByTargetAndSource(testUserId, testSource);
|
|
||||||
expect(suggestionsDataService.searchBy).toHaveBeenCalledWith('findByTargetAndSource', options, true, true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should call suggestionsDataService.delete', () => {
|
|
||||||
service.deleteSuggestion('1');
|
|
||||||
expect(suggestionsDataService.delete).toHaveBeenCalledWith('1');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Request service', () => {
|
|
||||||
it('should call requestService.setStaleByHrefSubstring', () => {
|
|
||||||
service.clearSuggestionRequests();
|
|
||||||
expect(requestService.setStaleByHrefSubstring).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@@ -1,138 +0,0 @@
|
|||||||
import { TestScheduler } from 'rxjs/testing';
|
|
||||||
import { RequestService } from '../../../data/request.service';
|
|
||||||
import { RemoteDataBuildService } from '../../../cache/builders/remote-data-build.service';
|
|
||||||
import { ObjectCacheService } from '../../../cache/object-cache.service';
|
|
||||||
import { HALEndpointService } from '../../../shared/hal-endpoint.service';
|
|
||||||
import { RequestEntry } from '../../../data/request-entry.model';
|
|
||||||
import { cold, getTestScheduler } from 'jasmine-marbles';
|
|
||||||
import { RestResponse } from '../../../cache/response.models';
|
|
||||||
import { of as observableOf } from 'rxjs';
|
|
||||||
import { Store } from '@ngrx/store';
|
|
||||||
import { CoreState } from '../../../core-state.model';
|
|
||||||
import { HttpClient } from '@angular/common/http';
|
|
||||||
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
|
|
||||||
import { SearchData } from '../../../data/base/search-data';
|
|
||||||
import { testSearchDataImplementation } from '../../../data/base/search-data.spec';
|
|
||||||
import { SuggestionTargetDataService } from './suggestion-target-data.service';
|
|
||||||
import { DefaultChangeAnalyzer } from '../../../data/default-change-analyzer.service';
|
|
||||||
import { SuggestionTarget } from '../models/suggestion-target.model';
|
|
||||||
import { testFindAllDataImplementation } from '../../../data/base/find-all-data.spec';
|
|
||||||
import { FindAllData } from '../../../data/base/find-all-data';
|
|
||||||
import { GetRequest } from '../../../data/request.models';
|
|
||||||
import {
|
|
||||||
createSuccessfulRemoteDataObject$
|
|
||||||
} from '../../../../shared/remote-data.utils';
|
|
||||||
import { RequestParam } from '../../../cache/models/request-param.model';
|
|
||||||
import { RemoteData } from '../../../data/remote-data';
|
|
||||||
import { RequestEntryState } from '../../../data/request-entry-state.model';
|
|
||||||
|
|
||||||
describe('SuggestionTargetDataService test', () => {
|
|
||||||
let scheduler: TestScheduler;
|
|
||||||
let service: SuggestionTargetDataService;
|
|
||||||
let requestService: RequestService;
|
|
||||||
let rdbService: RemoteDataBuildService;
|
|
||||||
let objectCache: ObjectCacheService;
|
|
||||||
let halService: HALEndpointService;
|
|
||||||
let notificationsService: NotificationsService;
|
|
||||||
let http: HttpClient;
|
|
||||||
let comparator: DefaultChangeAnalyzer<SuggestionTarget>;
|
|
||||||
let responseCacheEntry: RequestEntry;
|
|
||||||
|
|
||||||
const store = {} as Store<CoreState>;
|
|
||||||
const endpointURL = `https://rest.api/rest/api/suggestiontargets`;
|
|
||||||
const requestUUID = '8b3c613a-5a4b-438b-9686-be1d5b4a1c5a';
|
|
||||||
|
|
||||||
const remoteDataMocks = {
|
|
||||||
Success: new RemoteData(null, null, null, RequestEntryState.Success, null, null, 200),
|
|
||||||
};
|
|
||||||
|
|
||||||
function initTestService() {
|
|
||||||
return new SuggestionTargetDataService(
|
|
||||||
requestService,
|
|
||||||
rdbService,
|
|
||||||
store,
|
|
||||||
objectCache,
|
|
||||||
halService,
|
|
||||||
notificationsService,
|
|
||||||
http,
|
|
||||||
comparator
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
scheduler = getTestScheduler();
|
|
||||||
|
|
||||||
objectCache = {} as ObjectCacheService;
|
|
||||||
http = {} as HttpClient;
|
|
||||||
notificationsService = {} as NotificationsService;
|
|
||||||
comparator = {} as DefaultChangeAnalyzer<SuggestionTarget>;
|
|
||||||
responseCacheEntry = new RequestEntry();
|
|
||||||
responseCacheEntry.request = { href: 'https://rest.api/' } as any;
|
|
||||||
responseCacheEntry.response = new RestResponse(true, 200, 'Success');
|
|
||||||
|
|
||||||
requestService = jasmine.createSpyObj('requestService', {
|
|
||||||
generateRequestId: requestUUID,
|
|
||||||
send: true,
|
|
||||||
removeByHrefSubstring: {},
|
|
||||||
getByHref: observableOf(responseCacheEntry),
|
|
||||||
getByUUID: observableOf(responseCacheEntry),
|
|
||||||
});
|
|
||||||
|
|
||||||
halService = jasmine.createSpyObj('halService', {
|
|
||||||
getEndpoint: observableOf(endpointURL)
|
|
||||||
});
|
|
||||||
|
|
||||||
rdbService = jasmine.createSpyObj('rdbService', {
|
|
||||||
buildSingle: createSuccessfulRemoteDataObject$({}, 500),
|
|
||||||
buildList: cold('a', { a: remoteDataMocks.Success })
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
service = initTestService();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('composition', () => {
|
|
||||||
const initSearchService = () => new SuggestionTargetDataService(null, null, null, null, null, null, null, null) as unknown as SearchData<any>;
|
|
||||||
const initFindAllService = () => new SuggestionTargetDataService(null, null, null, null, null, null, null, null) as unknown as FindAllData<any>;
|
|
||||||
testSearchDataImplementation(initSearchService);
|
|
||||||
testFindAllDataImplementation(initFindAllService);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getTargetById', () => {
|
|
||||||
it('should send a new GetRequest', () => {
|
|
||||||
const expected = new GetRequest(requestService.generateRequestId(), endpointURL + '/testId');
|
|
||||||
scheduler.schedule(() => service.getTargetById('testId').subscribe());
|
|
||||||
scheduler.flush();
|
|
||||||
|
|
||||||
expect(requestService.send).toHaveBeenCalledWith(expected, true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getTargetsByUser', () => {
|
|
||||||
it('should send a new GetRequest', () => {
|
|
||||||
const options = {
|
|
||||||
searchParams: [new RequestParam('target', 'testId')]
|
|
||||||
};
|
|
||||||
const searchFindByTargetMethod = 'findByTarget';
|
|
||||||
const expected = new GetRequest(requestService.generateRequestId(), `${endpointURL}/search/${searchFindByTargetMethod}?target=testId`);
|
|
||||||
scheduler.schedule(() => service.getTargetsByUser('testId', options).subscribe());
|
|
||||||
scheduler.flush();
|
|
||||||
|
|
||||||
expect(requestService.send).toHaveBeenCalledWith(expected, true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getTargets', () => {
|
|
||||||
it('should send a new GetRequest', () => {
|
|
||||||
const options = {
|
|
||||||
searchParams: [new RequestParam('source', 'testId')]
|
|
||||||
};
|
|
||||||
const searchFindBySourceMethod = 'findBySource';
|
|
||||||
const expected = new GetRequest(requestService.generateRequestId(), `${endpointURL}/search/${searchFindBySourceMethod}?source=testId`);
|
|
||||||
scheduler.schedule(() => service.getTargets('testId', options).subscribe());
|
|
||||||
scheduler.flush();
|
|
||||||
|
|
||||||
expect(requestService.send).toHaveBeenCalledWith(expected, true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@@ -1,81 +0,0 @@
|
|||||||
import { SuggestionListElementComponent } from './suggestion-list-element.component';
|
|
||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
|
||||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
|
||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
|
||||||
import { TestScheduler } from 'rxjs/testing';
|
|
||||||
import { getTestScheduler } from 'jasmine-marbles';
|
|
||||||
import { mockSuggestionPublicationOne } from '../../../shared/mocks/reciter-suggestion.mock';
|
|
||||||
import { Item } from '../../../core/shared/item.model';
|
|
||||||
|
|
||||||
|
|
||||||
describe('SuggestionListElementComponent', () => {
|
|
||||||
let component: SuggestionListElementComponent;
|
|
||||||
let fixture: ComponentFixture<SuggestionListElementComponent>;
|
|
||||||
let scheduler: TestScheduler;
|
|
||||||
|
|
||||||
|
|
||||||
beforeEach(async(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
imports: [
|
|
||||||
TranslateModule.forRoot()
|
|
||||||
],
|
|
||||||
declarations: [SuggestionListElementComponent],
|
|
||||||
providers: [
|
|
||||||
NgbModal
|
|
||||||
],
|
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
|
||||||
}).compileComponents().then();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(SuggestionListElementComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
scheduler = getTestScheduler();
|
|
||||||
|
|
||||||
component.object = mockSuggestionPublicationOne;
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('SuggestionListElementComponent test', () => {
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
scheduler.schedule(() => fixture.detectChanges());
|
|
||||||
scheduler.flush();
|
|
||||||
const expectedIndexableObject = Object.assign(new Item(), {
|
|
||||||
id: mockSuggestionPublicationOne.id,
|
|
||||||
metadata: mockSuggestionPublicationOne.metadata
|
|
||||||
});
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
expect(component.listableObject.hitHighlights).toEqual({});
|
|
||||||
expect(component.listableObject.indexableObject).toEqual(expectedIndexableObject);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should check if has evidence', () => {
|
|
||||||
expect(component.hasEvidences()).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should set seeEvidences', () => {
|
|
||||||
component.onSeeEvidences(true);
|
|
||||||
expect(component.seeEvidence).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should emit selection', () => {
|
|
||||||
spyOn(component.selected, 'next');
|
|
||||||
component.changeSelected({target: { checked: true}});
|
|
||||||
expect(component.selected.next).toHaveBeenCalledWith(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should emit for deletion', () => {
|
|
||||||
spyOn(component.notMineClicked, 'emit');
|
|
||||||
component.onNotMine('1234');
|
|
||||||
expect(component.notMineClicked.emit).toHaveBeenCalledWith('1234');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should emit for approve and import', () => {
|
|
||||||
const event = {collectionId:'1234', suggestion: mockSuggestionPublicationOne};
|
|
||||||
spyOn(component.approveAndImport, 'emit');
|
|
||||||
component.onApproveAndImport(event);
|
|
||||||
expect(component.approveAndImport.emit).toHaveBeenCalledWith(event);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@@ -287,20 +287,20 @@ import { QualityAssuranceSourceDataService } from '../core/notifications/qa/sour
|
|||||||
import { DynamicComponentLoaderDirective } from './abstract-component-loader/dynamic-component-loader.directive';
|
import { DynamicComponentLoaderDirective } from './abstract-component-loader/dynamic-component-loader.directive';
|
||||||
import { StartsWithLoaderComponent } from './starts-with/starts-with-loader.component';
|
import { StartsWithLoaderComponent } from './starts-with/starts-with-loader.component';
|
||||||
import { IpV4Validator } from './utils/ipV4.validator';
|
import { IpV4Validator } from './utils/ipV4.validator';
|
||||||
import { ObjectTableComponent } from "./object-table/object-table.component";
|
import { ObjectTableComponent } from './object-table/object-table.component';
|
||||||
import {
|
import {
|
||||||
AbstractTabulatableElementComponent
|
AbstractTabulatableElementComponent
|
||||||
} from "./object-collection/shared/objects-collection-tabulatable/objects-collection-tabulatable.component";
|
} from './object-collection/shared/objects-collection-tabulatable/objects-collection-tabulatable.component';
|
||||||
import {
|
import {
|
||||||
TabulatableObjectsLoaderComponent
|
TabulatableObjectsLoaderComponent
|
||||||
} from "./object-collection/shared/tabulatable-objects/tabulatable-objects-loader.component";
|
} from './object-collection/shared/tabulatable-objects/tabulatable-objects-loader.component';
|
||||||
import {
|
import {
|
||||||
TabulatableResultListElementsComponent
|
TabulatableResultListElementsComponent
|
||||||
} from "./object-list/search-result-list-element/tabulatable-search-result/tabulatable-result-list-elements.component";
|
} from './object-list/search-result-list-element/tabulatable-search-result/tabulatable-result-list-elements.component';
|
||||||
import {
|
import {
|
||||||
TabulatableObjectsDirective
|
TabulatableObjectsDirective
|
||||||
} from "./object-collection/shared/tabulatable-objects/tabulatable-objects.directive";
|
} from './object-collection/shared/tabulatable-objects/tabulatable-objects.directive';
|
||||||
import { NotificationBoxComponent } from "./notification-box/notification-box.component";
|
import { NotificationBoxComponent } from './notification-box/notification-box.component';
|
||||||
|
|
||||||
const MODULES = [
|
const MODULES = [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
|
@@ -562,9 +562,6 @@
|
|||||||
|
|
||||||
"admin.reports.collections.match_all_selected_filters": "Matching all selected filters",
|
"admin.reports.collections.match_all_selected_filters": "Matching all selected filters",
|
||||||
|
|
||||||
|
|
||||||
"admin.reports.items.title": "Metadata Query Report",
|
|
||||||
|
|
||||||
"admin.reports.items.breadcrumbs": "Metadata Query Report",
|
"admin.reports.items.breadcrumbs": "Metadata Query Report",
|
||||||
|
|
||||||
"admin.reports.items.head": "Metadata Query Report",
|
"admin.reports.items.head": "Metadata Query Report",
|
||||||
@@ -2639,10 +2636,6 @@
|
|||||||
|
|
||||||
"item.truncatable-part.show-less": "Collapse",
|
"item.truncatable-part.show-less": "Collapse",
|
||||||
|
|
||||||
"item.qa-event-notification.check.notification-info": "There are {{num}} pending suggestions related to your account",
|
|
||||||
|
|
||||||
"item.qa-event-notification-info.check.button": "View",
|
|
||||||
|
|
||||||
"mydspace.qa-event-notification.check.notification-info": "There are {{num}} pending suggestions related to your account",
|
"mydspace.qa-event-notification.check.notification-info": "There are {{num}} pending suggestions related to your account",
|
||||||
|
|
||||||
"mydspace.qa-event-notification-info.check.button": "View",
|
"mydspace.qa-event-notification-info.check.button": "View",
|
||||||
@@ -3479,8 +3472,6 @@
|
|||||||
|
|
||||||
"quality-assurance.topics.description": "Below you can see all the topics received from the subscriptions to {{source}}.",
|
"quality-assurance.topics.description": "Below you can see all the topics received from the subscriptions to {{source}}.",
|
||||||
|
|
||||||
"quality-assurance.topics.description-with-target": "Below you can see all the topics received from the subscriptions to {{source}} in regards to the",
|
|
||||||
|
|
||||||
"quality-assurance.source.description": "Below you can see all the notification's sources.",
|
"quality-assurance.source.description": "Below you can see all the notification's sources.",
|
||||||
|
|
||||||
"quality-assurance.topics": "Current Topics",
|
"quality-assurance.topics": "Current Topics",
|
||||||
@@ -6166,10 +6157,6 @@
|
|||||||
|
|
||||||
"item.qa-event-notification-info.check.button": "Check",
|
"item.qa-event-notification-info.check.button": "Check",
|
||||||
|
|
||||||
"mydspace.qa-event-notification.check.notification-info": "There are {{num}} pending review to check",
|
|
||||||
|
|
||||||
"mydspace.qa-event-notification-info.check.button": "Check",
|
|
||||||
|
|
||||||
"item.page.endorsed-by": "Endorsement",
|
"item.page.endorsed-by": "Endorsement",
|
||||||
|
|
||||||
"item.page.is-reviewed-by": "Review",
|
"item.page.is-reviewed-by": "Review",
|
||||||
@@ -6643,5 +6630,5 @@
|
|||||||
|
|
||||||
"search.filters.filter.notifyEndorsement.placeholder": "Notify Endorsement",
|
"search.filters.filter.notifyEndorsement.placeholder": "Notify Endorsement",
|
||||||
|
|
||||||
"search.filters.filter.notifyEndorsement.label": "Search Notify Endorsement"
|
"search.filters.filter.notifyEndorsement.label": "Search Notify Endorsement",
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,7 @@ import { QualityAssuranceConfig } from './quality-assurance.config';
|
|||||||
import { SearchConfig } from './search-page-config.interface';
|
import { SearchConfig } from './search-page-config.interface';
|
||||||
import {
|
import {
|
||||||
AdminNotifyMetricsRow
|
AdminNotifyMetricsRow
|
||||||
} from "../app/admin/admin-notify-dashboard/admin-notify-metrics/admin-notify-metrics.model";
|
} from '../app/admin/admin-notify-dashboard/admin-notify-metrics/admin-notify-metrics.model';
|
||||||
interface AppConfig extends Config {
|
interface AppConfig extends Config {
|
||||||
ui: UIServerConfig;
|
ui: UIServerConfig;
|
||||||
rest: ServerConfig;
|
rest: ServerConfig;
|
||||||
|
@@ -28,7 +28,7 @@ import { QualityAssuranceConfig } from './quality-assurance.config';
|
|||||||
import { SearchConfig } from './search-page-config.interface';
|
import { SearchConfig } from './search-page-config.interface';
|
||||||
import {
|
import {
|
||||||
AdminNotifyMetricsRow
|
AdminNotifyMetricsRow
|
||||||
} from "../app/admin/admin-notify-dashboard/admin-notify-metrics/admin-notify-metrics.model";
|
} from '../app/admin/admin-notify-dashboard/admin-notify-metrics/admin-notify-metrics.model';
|
||||||
export class DefaultAppConfig implements AppConfig {
|
export class DefaultAppConfig implements AppConfig {
|
||||||
production = false;
|
production = false;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user