diff options
author | 2018-08-29 17:01:32 +0300 | |
---|---|---|
committer | 2019-02-18 18:35:30 +0200 | |
commit | 6f900cc45d7dd7f97430812b86b5c1d1693c8ae3 (patch) | |
tree | 936005c364dc5a7264d6304d4777c3d83494db22 /vid-webpack-master/src/app/shared/components/formControls/component/file/file.formControl.component.spec.ts | |
parent | 67d99f816cc583643c35193197594cf78d8ce60a (diff) |
merge from ecomp a88f0072 - Modern UI
Issue-ID: VID-378
Change-Id: Ibcb23dd27f550cf32ce2fe0239f0f496ae014ff6
Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-webpack-master/src/app/shared/components/formControls/component/file/file.formControl.component.spec.ts')
-rw-r--r-- | vid-webpack-master/src/app/shared/components/formControls/component/file/file.formControl.component.spec.ts | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/vid-webpack-master/src/app/shared/components/formControls/component/file/file.formControl.component.spec.ts b/vid-webpack-master/src/app/shared/components/formControls/component/file/file.formControl.component.spec.ts new file mode 100644 index 000000000..e27f5115a --- /dev/null +++ b/vid-webpack-master/src/app/shared/components/formControls/component/file/file.formControl.component.spec.ts @@ -0,0 +1,62 @@ +import {ComponentFixture, TestBed} from '@angular/core/testing'; +import {CUSTOM_ELEMENTS_SCHEMA} from '@angular/core' +import {FileFormControlComponent} from "./file.formControl.component"; +import {CommonModule} from "@angular/common"; +import {FormBuilder, FormControl, ReactiveFormsModule, Validators} from "@angular/forms"; +import {ValidatorModel, ValidatorOptions} from "../../../../models/formControlModels/formControl.model"; +import {FormControlMessageErrorComponent} from "../../errorMessage/formControlMessageError.component"; +import {BrowserModule} from "@angular/platform-browser"; +import {TooltipModule} from "ngx-tooltip"; +import {FileFormControl} from "../../../../models/formControlModels/fileFormControl.model"; + +describe('File Form Control Component', () => { + let component: FileFormControlComponent; + let fixture: ComponentFixture<FileFormControlComponent>; + let fb: FormBuilder; + + + beforeAll(done => (async () => { + TestBed.configureTestingModule({ + imports: [CommonModule, BrowserModule, ReactiveFormsModule, TooltipModule], + providers: [FormBuilder], + declarations: [FileFormControlComponent, FormControlMessageErrorComponent], + schemas: [CUSTOM_ELEMENTS_SCHEMA] + }); + await TestBed.compileComponents(); + + fixture = TestBed.createComponent(FileFormControlComponent); + component = fixture.componentInstance; + fb = TestBed.get(FormBuilder); + + })().then(done).catch(done.fail)); + + test('file component should initialize basic parameters', () => { + component.data = new FileFormControl({ + displayName: "display Name", + validations: [new ValidatorModel(ValidatorOptions.required, 'is required')], + dataTestId: "data-test-id", + placeHolder: "place holder", + controlName: 'testFile', + acceptedExtentions: "json" + }); + + component.form = fb.group({ + 'testFile': new FormControl({ + value: component.data.selectedFile, + disabled: false + }, + Validators.compose(component.data.validations.map(item => item.validator)) + ), + }); + + component.data.onDelete = function () { + component.form.controls['testFile'].setValue('onDelete'); + }; + + expect(component.form.controls['testFile'].value).toEqual("place holder"); + let event = new Event("onDelete", null); + component.data.onDelete(event, component.data, component.form); + expect(component.form.controls['testFile'].value).toEqual('onDelete'); + }) +}); + |