mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
87968: Fix unit tests
This commit is contained in:
@@ -77,6 +77,7 @@ import { createSuccessfulRemoteDataObject } from '../../../remote-data.utils';
|
||||
import { FormService } from '../../form.service';
|
||||
import { SubmissionService } from '../../../../submission/submission.service';
|
||||
import { FormBuilderService } from '../form-builder.service';
|
||||
import { NgxMaskModule } from 'ngx-mask';
|
||||
|
||||
describe('DsDynamicFormControlContainerComponent test suite', () => {
|
||||
|
||||
@@ -194,6 +195,7 @@ describe('DsDynamicFormControlContainerComponent test suite', () => {
|
||||
DynamicFormsCoreModule.forRoot(),
|
||||
SharedModule,
|
||||
TranslateModule.forRoot(),
|
||||
NgxMaskModule.forRoot(),
|
||||
],
|
||||
providers: [
|
||||
DsDynamicFormControlContainerComponent,
|
||||
|
@@ -104,7 +104,7 @@ describe('FormBuilderService test suite', () => {
|
||||
new DynamicInputModel(
|
||||
{
|
||||
id: 'testInput',
|
||||
mask: ['(', /[1-9]/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/],
|
||||
mask: '(000) 000-0000',
|
||||
}
|
||||
),
|
||||
|
||||
|
@@ -170,7 +170,7 @@ describe('ClaimedTaskActionsComponent', () => {
|
||||
fixture.whenStable().then(() => {
|
||||
const debugElement = fixture.debugElement.query(By.css('.workflow-view'));
|
||||
expect(debugElement).toBeTruthy();
|
||||
expect(debugElement.nativeElement.innerText).toBe('submission.workflow.generic.view');
|
||||
expect(debugElement.nativeElement.innerText.trim()).toBe('submission.workflow.generic.view');
|
||||
});
|
||||
|
||||
}));
|
||||
|
@@ -32,14 +32,15 @@ const searchService = getMockSearchService();
|
||||
|
||||
const requestService = getMockRequestService();
|
||||
|
||||
let mockPoolTaskDataService: PoolTaskDataService;
|
||||
|
||||
describe('ClaimedTaskActionsRejectComponent', () => {
|
||||
const object = Object.assign(new ClaimedTask(), { id: 'claimed-task-1' });
|
||||
|
||||
const claimedTaskService = jasmine.createSpyObj('claimedTaskService', {
|
||||
submitTask: of(new ProcessTaskResponse(true))
|
||||
});
|
||||
|
||||
let mockPoolTaskDataService: PoolTaskDataService;
|
||||
|
||||
describe('ClaimedTaskActionsRejectComponent', () => {
|
||||
beforeEach(waitForAsync(() => {
|
||||
mockPoolTaskDataService = new PoolTaskDataService(null, null, null, null, null, null, null, null);
|
||||
TestBed.configureTestingModule({
|
||||
@@ -69,9 +70,6 @@ describe('ClaimedTaskActionsRejectComponent', () => {
|
||||
}).overrideComponent(ClaimedTaskActionsRejectComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ClaimedTaskActionsRejectComponent);
|
||||
component = fixture.componentInstance;
|
||||
formBuilder = TestBed.inject(FormBuilder);
|
||||
@@ -80,7 +78,7 @@ describe('ClaimedTaskActionsRejectComponent', () => {
|
||||
component.modalRef = modalService.open('ok');
|
||||
spyOn(component, 'initReloadAnchor').and.returnValue(undefined);
|
||||
fixture.detectChanges();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should init reject form properly', () => {
|
||||
expect(component.rejectForm).toBeDefined();
|
||||
|
@@ -132,7 +132,8 @@ describe('WorkspaceitemActionsComponent', () => {
|
||||
expect(btn).toBeDefined();
|
||||
});
|
||||
|
||||
it('should call confirmDiscard on discard confirmation', () => {
|
||||
describe('on discard confirmation', () => {
|
||||
beforeEach((done) => {
|
||||
mockDataService.delete.and.returnValue(observableOf(true));
|
||||
spyOn(component, 'reload');
|
||||
const btn = fixture.debugElement.query(By.css('.btn-danger'));
|
||||
@@ -145,9 +146,13 @@ describe('WorkspaceitemActionsComponent', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
expect(mockDataService.delete).toHaveBeenCalledWith(mockObject.id);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should call confirmDiscard', () => {
|
||||
expect(mockDataService.delete).toHaveBeenCalledWith(mockObject.id);
|
||||
});
|
||||
});
|
||||
|
||||
it('should display a success notification on delete success', waitForAsync(() => {
|
||||
|
@@ -16,6 +16,10 @@ import { SubmissionFormFooterComponent } from './submission-form-footer.componen
|
||||
import { SubmissionRestService } from '../../../core/submission/submission-rest.service';
|
||||
import { createTestComponent } from '../../../shared/testing/utils.test';
|
||||
|
||||
const submissionServiceStub: SubmissionServiceStub = new SubmissionServiceStub();
|
||||
|
||||
const submissionId = mockSubmissionId;
|
||||
|
||||
describe('SubmissionFormFooterComponent Component', () => {
|
||||
|
||||
let comp: SubmissionFormFooterComponent;
|
||||
@@ -24,9 +28,6 @@ describe('SubmissionFormFooterComponent Component', () => {
|
||||
let submissionRestServiceStub: SubmissionRestServiceStub;
|
||||
let scheduler: TestScheduler;
|
||||
|
||||
const submissionServiceStub: SubmissionServiceStub = new SubmissionServiceStub();
|
||||
const submissionId = mockSubmissionId;
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
@@ -182,7 +183,8 @@ describe('SubmissionFormFooterComponent Component', () => {
|
||||
expect(submissionServiceStub.dispatchDeposit).toHaveBeenCalledWith(submissionId);
|
||||
});
|
||||
|
||||
it('should call dispatchDiscard on discard confirmation', (done) => {
|
||||
describe('on discard confirmation', () => {
|
||||
beforeEach((done) => {
|
||||
comp.showDepositAndDiscard = observableOf(true);
|
||||
fixture.detectChanges();
|
||||
const modalBtn = fixture.debugElement.query(By.css('.btn-danger'));
|
||||
@@ -191,16 +193,22 @@ describe('SubmissionFormFooterComponent Component', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
const confirmBtn: any = ((document as any).querySelector('.btn-danger:nth-child(2)'));
|
||||
|
||||
console.log(confirmBtn);
|
||||
|
||||
confirmBtn.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
expect(submissionServiceStub.dispatchDiscard).toHaveBeenCalledWith(submissionId);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should call dispatchDiscard', () => {
|
||||
expect(submissionServiceStub.dispatchDiscard).toHaveBeenCalledWith(submissionId);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not have deposit button disabled when submission is not valid', () => {
|
||||
comp.showDepositAndDiscard = observableOf(true);
|
||||
compAsAny.submissionIsInvalid = observableOf(true);
|
||||
|
Reference in New Issue
Block a user