diff --git a/src/app/+collection-page/edit-collection-page/collection-source/collection-source.component.spec.ts b/src/app/+collection-page/edit-collection-page/collection-source/collection-source.component.spec.ts index 454634ebfc..89d7445b65 100644 --- a/src/app/+collection-page/edit-collection-page/collection-source/collection-source.component.spec.ts +++ b/src/app/+collection-page/edit-collection-page/collection-source/collection-source.component.spec.ts @@ -109,22 +109,30 @@ describe('CollectionSourceComponent', () => { }); describe('on startup', () => { + let form; + + beforeEach(() => { + form = fixture.debugElement.query(By.css('ds-form')); + }); + it('ContentSource should be disabled', () => { expect(comp.contentSource.enabled).toBe(false); }); - it('the input-form should be disabled', () => { - expect(comp.formGroup.disabled).toBe(true); + it('the input-form should be hidden', () => { + expect(form).toBeNull(); }); }); describe('when selecting the checkbox', () => { let input; + let form; beforeEach(() => { input = fixture.debugElement.query(By.css('#externalSourceCheck')).nativeElement; input.click(); fixture.detectChanges(); + form = fixture.debugElement.query(By.css('ds-form')); }); it('should enable ContentSource', () => { @@ -134,6 +142,10 @@ describe('CollectionSourceComponent', () => { it('should send a field update', () => { expect(objectUpdatesService.saveAddFieldUpdate).toHaveBeenCalledWith(router.url, comp.contentSource) }); + + it('should display the form', () => { + expect(form).not.toBeNull(); + }); }); describe('isValid', () => { @@ -155,4 +167,20 @@ describe('CollectionSourceComponent', () => { expect(comp.isValid()).toBe(true); }); }); + + describe('onSubmit', () => { + beforeEach(() => { + comp.onSubmit(); + }); + + it('should re-initialize the field updates', () => { + expect(objectUpdatesService.initialize).toHaveBeenCalled(); + }); + + it('should display a success notification', () => { + expect(notificationsService.success).toHaveBeenCalled(); + }); + + // TODO: Write test for sending data to REST API on submit + }); });