From d996aadbcc234893b56e443ac9bf2681e889cffc Mon Sep 17 00:00:00 2001 From: Maurizio Vitale Date: Mon, 20 Jun 2022 09:29:55 +0100 Subject: [PATCH] Transform e2e into unit (#7671) --- .../components/form-cloud.component.spec.ts | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/lib/process-services-cloud/src/lib/form/components/form-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/form/components/form-cloud.component.spec.ts index 9980e10525..efd8925f1d 100644 --- a/lib/process-services-cloud/src/lib/form/components/form-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/form-cloud.component.spec.ts @@ -230,6 +230,41 @@ describe('FormCloudComponent', () => { expect(formComponent.isTitleEnabled()).toBeFalsy(); }); + it('should show a valid validation icon in case showValidationIcon is true', () => { + const formModel = new FormModel(); + formComponent.form = formModel; + + expect(formComponent.showValidationIcon).toBeTruthy(); + fixture.detectChanges(); + const validationSection = fixture.debugElement.query(By.css('.adf-form-validation-button')); + expect(validationSection).not.toBeNull(); + const validationIcon = fixture.debugElement.query(By.css('#adf-valid-form-icon')); + expect(validationIcon.nativeElement.innerText).toEqual('check_circle'); + }); + + it('should show a error icon in case showValidationIcon is true and form invalid', () => { + const formModel = new FormModel(); + formModel.isValid = false; + formComponent.form = formModel; + + expect(formComponent.showValidationIcon).toBeTruthy(); + fixture.detectChanges(); + const validationSection = fixture.debugElement.query(By.css('.adf-form-validation-button')); + expect(validationSection).not.toBeNull(); + const validationIcon = fixture.debugElement.query(By.css('#adf-invalid-form-icon')); + expect(validationIcon.nativeElement.innerText).toEqual('error'); + }); + + it('should not show any validation icon in case showValidationIcon is false', () => { + const formModel = new FormModel(); + formComponent.form = formModel; + formComponent.showValidationIcon = false; + + fixture.detectChanges(); + const validationSection = fixture.debugElement.query(By.css('.adf-form-validation-button')); + expect(validationSection).toBeNull(); + }); + it('should return primary color for complete button', () => { expect(formComponent.getColorForOutcome('COMPLETE')).toBe('primary'); });