mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-15 14:03:06 +00:00
Fix tests
This commit is contained in:
@@ -28,13 +28,15 @@ import {
|
||||
SectionStatusChangeAction,
|
||||
UpdateSectionDataAction
|
||||
} from '../objects/submission-objects.actions';
|
||||
import { FormAddError, FormClearErrorsAction, FormRemoveErrorAction } from '../../shared/form/form.actions';
|
||||
import { FormClearErrorsAction } from '../../shared/form/form.actions';
|
||||
import parseSectionErrors from '../utils/parseSectionErrors';
|
||||
import { SubmissionScopeType } from '../../core/submission/submission-scope-type';
|
||||
import { SubmissionSectionError } from '../objects/submission-objects.reducer';
|
||||
import { getMockScrollToService } from '../../shared/mocks/scroll-to-service.mock';
|
||||
import { storeModuleConfig } from '../../app.reducer';
|
||||
import { SectionsType } from './sections-type';
|
||||
import { FormService } from '../../shared/form/form.service';
|
||||
import { getMockFormService } from '../../shared/mocks/form-service.mock';
|
||||
|
||||
describe('SectionsService test suite', () => {
|
||||
let notificationsServiceStub: NotificationsServiceStub;
|
||||
@@ -57,6 +59,8 @@ describe('SectionsService test suite', () => {
|
||||
select: jasmine.createSpy('select')
|
||||
});
|
||||
|
||||
const formService: any = getMockFormService();
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
@@ -74,6 +78,7 @@ describe('SectionsService test suite', () => {
|
||||
{ provide: SubmissionService, useClass: SubmissionServiceStub },
|
||||
{ provide: TranslateService, useValue: getMockTranslateService() },
|
||||
{ provide: Store, useValue: store },
|
||||
{ provide: FormService, useValue: formService },
|
||||
SectionsService
|
||||
]
|
||||
}).compileComponents();
|
||||
@@ -98,22 +103,23 @@ describe('SectionsService test suite', () => {
|
||||
it('should dispatch a new FormAddError for each section\'s error', () => {
|
||||
service.checkSectionErrors(submissionId, sectionId, formId, sectionErrors[sectionId]);
|
||||
|
||||
expect(store.dispatch).toHaveBeenCalledWith(new FormAddError(
|
||||
expect(formService.addError).toHaveBeenCalledWith(
|
||||
formId,
|
||||
'dc_contributor_author',
|
||||
'dc.contributor.author',
|
||||
0,
|
||||
'error.validation.required'));
|
||||
'error.validation.required');
|
||||
|
||||
expect(store.dispatch).toHaveBeenCalledWith(new FormAddError(
|
||||
expect(formService.addError).toHaveBeenCalledWith(
|
||||
formId,
|
||||
'dc_title',
|
||||
'dc.title',
|
||||
0,
|
||||
'error.validation.required'));
|
||||
'error.validation.required');
|
||||
|
||||
expect(store.dispatch).toHaveBeenCalledWith(new FormAddError(formId,
|
||||
'dc_date_issued',
|
||||
expect(formService.addError).toHaveBeenCalledWith(
|
||||
formId,
|
||||
'dc.date.issued',
|
||||
0,
|
||||
'error.validation.required'));
|
||||
'error.validation.required');
|
||||
});
|
||||
|
||||
it('should dispatch a new FormRemoveErrorAction for each section\'s error that no longer exists', () => {
|
||||
@@ -123,21 +129,21 @@ describe('SectionsService test suite', () => {
|
||||
|
||||
service.checkSectionErrors(submissionId, sectionId, formId, currentErrors, prevErrors);
|
||||
|
||||
expect(store.dispatch).toHaveBeenCalledWith(new FormAddError(
|
||||
expect(formService.addError).toHaveBeenCalledWith(
|
||||
formId,
|
||||
'dc_contributor_author',
|
||||
'dc.contributor.author',
|
||||
0,
|
||||
'error.validation.required'));
|
||||
'error.validation.required');
|
||||
|
||||
expect(store.dispatch).toHaveBeenCalledWith(new FormAddError(
|
||||
expect(formService.addError).toHaveBeenCalledWith(
|
||||
formId,
|
||||
'dc_title',
|
||||
'dc.title',
|
||||
0,
|
||||
'error.validation.required'));
|
||||
expect(store.dispatch).toHaveBeenCalledWith(new FormRemoveErrorAction(
|
||||
'error.validation.required');
|
||||
expect(formService.removeError).toHaveBeenCalledWith(
|
||||
formId,
|
||||
'dc_date_issued',
|
||||
0));
|
||||
'dc.date.issued',
|
||||
0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -385,7 +391,7 @@ describe('SectionsService test suite', () => {
|
||||
scheduler.schedule(() => service.updateSectionData(submissionId, sectionId, data, []));
|
||||
scheduler.flush();
|
||||
|
||||
expect(store.dispatch).toHaveBeenCalledWith(new UpdateSectionDataAction(submissionId, sectionId, data, []));
|
||||
expect(store.dispatch).toHaveBeenCalledWith(new UpdateSectionDataAction(submissionId, sectionId, data, [], []));
|
||||
});
|
||||
|
||||
it('should dispatch a new UpdateSectionDataAction and display a new notification when section is not enabled', () => {
|
||||
@@ -397,7 +403,7 @@ describe('SectionsService test suite', () => {
|
||||
scheduler.schedule(() => service.updateSectionData(submissionId, sectionId, data, []));
|
||||
scheduler.flush();
|
||||
|
||||
expect(store.dispatch).toHaveBeenCalledWith(new UpdateSectionDataAction(submissionId, sectionId, data, []));
|
||||
expect(store.dispatch).toHaveBeenCalledWith(new UpdateSectionDataAction(submissionId, sectionId, data, [], []));
|
||||
});
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user