mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 02:24:11 +00:00
[TLC-674] New duplicate data service, object reducer tests
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
import { SubmissionDuplicateDataService } from './submission-duplicate-data.service';
|
||||||
|
import { FindListOptions } from '../data/find-list-options.model';
|
||||||
|
import { RequestParam } from '../cache/models/request-param.model';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Basic tests for the submission-duplicate-data.service.ts service
|
||||||
|
*/
|
||||||
|
describe('SubmissionDuplicateDataService', () => {
|
||||||
|
const duplicateDataService = new SubmissionDuplicateDataService(null, null, null, null);
|
||||||
|
|
||||||
|
// Test the findDuplicates method to make sure that a call results in an expected
|
||||||
|
// call to searchBy, using the 'findByItem' search method
|
||||||
|
describe('findDuplicates', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(duplicateDataService, 'searchBy');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call searchBy with the correct arguments', () => {
|
||||||
|
// Set up expected search parameters and find options
|
||||||
|
const searchParams = [];
|
||||||
|
searchParams.push(new RequestParam('uuid', 'test'));
|
||||||
|
let findListOptions = new FindListOptions();
|
||||||
|
findListOptions.searchParams = searchParams;
|
||||||
|
// Perform test search using uuid 'test' using the findDuplicates method
|
||||||
|
const result = duplicateDataService.findDuplicates('test', new FindListOptions(), true, true);
|
||||||
|
// Expect searchBy('findByItem'...) to have been used as SearchData impl with the expected options (uuid=test)
|
||||||
|
expect(duplicateDataService.searchBy).toHaveBeenCalledWith('findByItem', findListOptions, true, true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@@ -1114,7 +1114,10 @@ export const mockSubmissionState: SubmissionObjectState = Object.assign({}, {
|
|||||||
isLoading: false,
|
isLoading: false,
|
||||||
isValid: false,
|
isValid: false,
|
||||||
removePending: false
|
removePending: false
|
||||||
} as any
|
} as any,
|
||||||
|
'duplicates': {
|
||||||
|
potentialDuplicates: []
|
||||||
|
} as any,
|
||||||
},
|
},
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
savePending: false,
|
savePending: false,
|
||||||
|
@@ -867,6 +867,7 @@ export type SubmissionObjectAction = DisableSectionAction
|
|||||||
| InitSubmissionFormAction
|
| InitSubmissionFormAction
|
||||||
| ResetSubmissionFormAction
|
| ResetSubmissionFormAction
|
||||||
| CancelSubmissionFormAction
|
| CancelSubmissionFormAction
|
||||||
|
| CleanDuplicateDetectionAction
|
||||||
| CompleteInitSubmissionFormAction
|
| CompleteInitSubmissionFormAction
|
||||||
| ChangeSubmissionCollectionAction
|
| ChangeSubmissionCollectionAction
|
||||||
| SaveAndDepositSubmissionAction
|
| SaveAndDepositSubmissionAction
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { submissionObjectReducer, SubmissionObjectState } from './submission-objects.reducer';
|
import { submissionObjectReducer, SubmissionObjectState } from './submission-objects.reducer';
|
||||||
import {
|
import {
|
||||||
CancelSubmissionFormAction,
|
CancelSubmissionFormAction,
|
||||||
ChangeSubmissionCollectionAction,
|
ChangeSubmissionCollectionAction, CleanDuplicateDetectionAction,
|
||||||
CompleteInitSubmissionFormAction,
|
CompleteInitSubmissionFormAction,
|
||||||
DeleteSectionErrorsAction,
|
DeleteSectionErrorsAction,
|
||||||
DeleteUploadedFileAction,
|
DeleteUploadedFileAction,
|
||||||
@@ -273,7 +273,7 @@ describe('submissionReducer test suite', () => {
|
|||||||
expect(newState[826].sections.traditionalpagetwo.enabled).toBeTruthy();
|
expect(newState[826].sections.traditionalpagetwo.enabled).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should enable submission section properly', () => {
|
it('should disable submission section properly', () => {
|
||||||
|
|
||||||
let action: SubmissionObjectAction = new EnableSectionAction(submissionId, 'traditionalpagetwo');
|
let action: SubmissionObjectAction = new EnableSectionAction(submissionId, 'traditionalpagetwo');
|
||||||
let newState = submissionObjectReducer(initState, action);
|
let newState = submissionObjectReducer(initState, action);
|
||||||
@@ -644,4 +644,20 @@ describe('submissionReducer test suite', () => {
|
|||||||
expect(newState[826].sections.upload.data).toEqual(expectedState);
|
expect(newState[826].sections.upload.data).toEqual(expectedState);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should enable duplicates section properly', () => {
|
||||||
|
|
||||||
|
let action: SubmissionObjectAction = new EnableSectionAction(submissionId, 'duplicates');
|
||||||
|
let newState = submissionObjectReducer(initState, action);
|
||||||
|
|
||||||
|
expect(newState[826].sections.duplicates.enabled).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should clean duplicates section properly', () => {
|
||||||
|
|
||||||
|
let action = new CleanDuplicateDetectionAction(submissionId);
|
||||||
|
let newState = submissionObjectReducer(initState, action);
|
||||||
|
|
||||||
|
expect(newState[826].sections.duplicates.enabled).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user