mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 18:44:14 +00:00
[CST-4884] Test
This commit is contained in:
@@ -49,7 +49,7 @@ const jsonPatchOpBuilder: any = jasmine.createSpyObj('jsonPatchOpBuilder', {
|
|||||||
|
|
||||||
const formMetadataMock = ['dc.title', 'dc.description'];
|
const formMetadataMock = ['dc.title', 'dc.description'];
|
||||||
|
|
||||||
fdescribe('SubmissionSectionUploadFileEditComponent test suite', () => {
|
describe('SubmissionSectionUploadFileEditComponent test suite', () => {
|
||||||
|
|
||||||
let comp: SubmissionSectionUploadFileEditComponent;
|
let comp: SubmissionSectionUploadFileEditComponent;
|
||||||
let compAsAny: any;
|
let compAsAny: any;
|
||||||
@@ -98,6 +98,7 @@ fdescribe('SubmissionSectionUploadFileEditComponent test suite', () => {
|
|||||||
SubmissionSectionUploadFileEditComponent,
|
SubmissionSectionUploadFileEditComponent,
|
||||||
NgbModal,
|
NgbModal,
|
||||||
NgbActiveModal,
|
NgbActiveModal,
|
||||||
|
FormComponent,
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).compileComponents().then();
|
}).compileComponents().then();
|
||||||
@@ -157,6 +158,8 @@ fdescribe('SubmissionSectionUploadFileEditComponent test suite', () => {
|
|||||||
comp.fileId = fileId;
|
comp.fileId = fileId;
|
||||||
comp.configMetadataForm = configMetadataForm;
|
comp.configMetadataForm = configMetadataForm;
|
||||||
comp.formMetadata = formMetadataMock;
|
comp.formMetadata = formMetadataMock;
|
||||||
|
|
||||||
|
formService.isValid.and.returnValue(of(true));
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@@ -233,12 +236,9 @@ fdescribe('SubmissionSectionUploadFileEditComponent test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should save Bitstream File data properly when form is valid', fakeAsync(() => {
|
it('should save Bitstream File data properly when form is valid', fakeAsync(() => {
|
||||||
compAsAny.fileEditComp = TestBed.inject(SubmissionSectionUploadFileEditComponent);
|
compAsAny.formRef = {formGroup: null};
|
||||||
compAsAny.fileEditComp.formRef = {formGroup: null};
|
|
||||||
compAsAny.fileData = fileData;
|
compAsAny.fileData = fileData;
|
||||||
compAsAny.pathCombiner = pathCombiner;
|
compAsAny.pathCombiner = pathCombiner;
|
||||||
// const event = new Event('click', null);
|
|
||||||
// spyOn(comp, 'switchMode');
|
|
||||||
formService.validateAllFormFields.and.callFake(() => null);
|
formService.validateAllFormFields.and.callFake(() => null);
|
||||||
formService.isValid.and.returnValue(of(true));
|
formService.isValid.and.returnValue(of(true));
|
||||||
formService.getFormData.and.returnValue(of(mockFileFormData));
|
formService.getFormData.and.returnValue(of(mockFileFormData));
|
||||||
@@ -283,21 +283,18 @@ fdescribe('SubmissionSectionUploadFileEditComponent test suite', () => {
|
|||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
// expect(comp.switchMode).toHaveBeenCalled();
|
|
||||||
expect(uploadService.updateFileData).toHaveBeenCalledWith(submissionId, sectionId, mockUploadFiles[0].uuid, mockUploadFiles[0]);
|
expect(uploadService.updateFileData).toHaveBeenCalledWith(submissionId, sectionId, mockUploadFiles[0].uuid, mockUploadFiles[0]);
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should not save Bitstream File data properly when form is not valid', fakeAsync(() => {
|
it('should not save Bitstream File data properly when form is not valid', fakeAsync(() => {
|
||||||
compAsAny.fileEditComp = TestBed.inject(SubmissionSectionUploadFileEditComponent);
|
compAsAny.formRef = {formGroup: null};
|
||||||
compAsAny.fileEditComp.formRef = {formGroup: null};
|
|
||||||
compAsAny.pathCombiner = pathCombiner;
|
compAsAny.pathCombiner = pathCombiner;
|
||||||
// const event = new Event('click', null);
|
|
||||||
// spyOn(comp, 'switchMode');
|
|
||||||
formService.validateAllFormFields.and.callFake(() => null);
|
formService.validateAllFormFields.and.callFake(() => null);
|
||||||
formService.isValid.and.returnValue(of(false));
|
formService.isValid.and.returnValue(of(false));
|
||||||
|
comp.saveBitstreamData();
|
||||||
|
tick();
|
||||||
|
|
||||||
// expect(comp.switchMode).not.toHaveBeenCalled();
|
|
||||||
expect(uploadService.updateFileData).not.toHaveBeenCalled();
|
expect(uploadService.updateFileData).not.toHaveBeenCalled();
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
@@ -44,7 +44,7 @@ const configMetadataFormMock = {
|
|||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
|
|
||||||
fdescribe('SubmissionSectionUploadFileComponent test suite', () => {
|
describe('SubmissionSectionUploadFileComponent test suite', () => {
|
||||||
|
|
||||||
let comp: SubmissionSectionUploadFileComponent;
|
let comp: SubmissionSectionUploadFileComponent;
|
||||||
let compAsAny: any;
|
let compAsAny: any;
|
||||||
|
Reference in New Issue
Block a user