Skip to content

Commit 4e00460

Browse files
committed
113500: Fixed tests after bugfix
1 parent 993ce1a commit 4e00460

2 files changed

Lines changed: 16 additions & 13 deletions

File tree

src/app/submission/sections/form/section-form.component.spec.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -261,15 +261,15 @@ describe('SubmissionSectionFormComponent test suite', () => {
261261
expect(comp.sectionData.errorsToShow).toEqual([]);
262262
expect(comp.sectionData.data).toEqual(sectionData);
263263
expect(comp.isLoading).toBeFalsy();
264-
expect(comp.initForm).toHaveBeenCalledWith(sectionData);
264+
expect(comp.initForm).toHaveBeenCalledWith(sectionData, [], []);
265265
expect(comp.subscriptions).toHaveBeenCalled();
266266
});
267267

268268
it('should init form model properly', () => {
269269
formBuilderService.modelFromConfiguration.and.returnValue(testFormModel);
270270
const sectionData = {};
271271

272-
comp.initForm(sectionData);
272+
comp.initForm(sectionData, [], []);
273273

274274
expect(comp.formModel).toEqual(testFormModel);
275275

@@ -284,7 +284,7 @@ describe('SubmissionSectionFormComponent test suite', () => {
284284
path: '/sections/' + sectionObject.id
285285
};
286286

287-
comp.initForm(sectionData);
287+
comp.initForm(sectionData, [], []);
288288

289289
expect(comp.formModel).toBeUndefined();
290290
expect(sectionsServiceStub.setSectionError).toHaveBeenCalledWith(submissionId, sectionObject.id, sectionError);
@@ -443,7 +443,7 @@ describe('SubmissionSectionFormComponent test suite', () => {
443443
compAsAny.formData = {};
444444
compAsAny.sectionMetadata = ['dc.title'];
445445

446-
comp.updateForm(sectionData, sectionError);
446+
comp.updateForm({data: sectionData, errorsToShow: sectionError} as any);
447447

448448
expect(comp.isUpdating).toBeFalsy();
449449
expect(comp.initForm).toHaveBeenCalled();
@@ -455,15 +455,19 @@ describe('SubmissionSectionFormComponent test suite', () => {
455455
it('should update form error properly', () => {
456456
spyOn(comp, 'initForm');
457457
spyOn(comp, 'checksForErrors');
458-
const sectionData: any = {
458+
const sectionData = {
459459
'dc.title': [new FormFieldMetadataValueObject('test')]
460460
};
461+
const sectionState = {
462+
data: sectionData,
463+
errorsToShow: [{path: '/test', message: 'test'}],
464+
} as any;
461465
comp.sectionData.data = {};
462466
comp.sectionData.errorsToShow = [];
463467
compAsAny.formData = sectionData;
464468
compAsAny.sectionMetadata = ['dc.title'];
465469

466-
comp.updateForm(sectionData, parsedSectionErrors);
470+
comp.updateForm(sectionState);
467471

468472
expect(comp.initForm).not.toHaveBeenCalled();
469473
expect(comp.checksForErrors).toHaveBeenCalled();
@@ -474,8 +478,9 @@ describe('SubmissionSectionFormComponent test suite', () => {
474478
spyOn(comp, 'initForm');
475479
spyOn(comp, 'checksForErrors');
476480
const sectionData: any = {};
481+
const sectionErrors: any = [{ path: '/test', message: 'test'}];
477482

478-
comp.updateForm(sectionData, parsedSectionErrors);
483+
comp.updateForm({data: sectionData, errorsToShow: sectionErrors} as any);
479484

480485
expect(comp.initForm).not.toHaveBeenCalled();
481486
expect(comp.checksForErrors).toHaveBeenCalled();
@@ -541,7 +546,7 @@ describe('SubmissionSectionFormComponent test suite', () => {
541546
const sectionState = {
542547
data: sectionData,
543548
errorsToShow: parsedSectionErrors
544-
};
549+
} as any;
545550

546551
formService.getFormData.and.returnValue(observableOf(formData));
547552
sectionsServiceStub.getSectionState.and.returnValue(observableOf(sectionState));
@@ -550,7 +555,7 @@ describe('SubmissionSectionFormComponent test suite', () => {
550555

551556
expect(compAsAny.subs.length).toBe(2);
552557
expect(compAsAny.formData).toEqual(formData);
553-
expect(comp.updateForm).toHaveBeenCalledWith(sectionState.data, sectionState.errorsToShow);
558+
expect(comp.updateForm).toHaveBeenCalledWith(sectionState);
554559

555560
});
556561

src/app/submission/sections/form/section-form.component.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,8 @@ export class SubmissionSectionFormComponent extends SectionModelComponent {
322322
/**
323323
* Update form model
324324
*
325-
* @param sectionData
326-
* the section data retrieved from the server
327-
* @param errors
328-
* the section errors retrieved from the server
325+
* @param sectionState
326+
* the section state retrieved from the server
329327
*/
330328
updateForm(sectionState: SubmissionSectionObject): void {
331329

0 commit comments

Comments
 (0)