diff options
author | 2019-12-18 21:04:38 +0200 | |
---|---|---|
committer | 2019-12-22 14:01:45 +0200 | |
commit | 4c87ecaa8cce40f078f8540a15928e7e805e4ef7 (patch) | |
tree | f31c55200451d13f108c8583b8d275ae7a7c8bab /vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/basic.control.generator.spec.ts | |
parent | 54af5cdca044c7b486f02f4163d16c39e990f701 (diff) |
Refactor Generic Generators
Issue-ID: VID-731
Signed-off-by: Yoav Schneiderman <yoav.schneiderman@intl.att.com>
Change-Id: Ib851ff4056d64e12eaf415c5d689c832196ec8b0
Signed-off-by: Yoav Schneiderman <yoav.schneiderman@intl.att.com>
Diffstat (limited to 'vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/basic.control.generator.spec.ts')
-rw-r--r-- | vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/basic.control.generator.spec.ts | 108 |
1 files changed, 0 insertions, 108 deletions
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/basic.control.generator.spec.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/basic.control.generator.spec.ts deleted file mode 100644 index 7e2d3f942..000000000 --- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/basic.control.generator.spec.ts +++ /dev/null @@ -1,108 +0,0 @@ -import {getTestBed, TestBed} from '@angular/core/testing'; -import {AaiService} from "../../../services/aaiService/aai.service"; -import {FormControlModel} from "../../../models/formControlModels/formControl.model"; -import {FeatureFlagsService} from "../../../services/featureFlag/feature-flags.service"; -import {BasicControlGenerator} from "./basic.control.generator"; -import {NgRedux} from '@angular-redux/store'; -import each from "jest-each"; -import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing'; -import {FileFormControl} from "../../../models/formControlModels/fileFormControl.model"; - -class MockAppStore<T> {} - -class MockFeatureFlagsService {} - -describe('Basic Control Generator', () => { - let injector; - let service: BasicControlGenerator; - let httpMock: HttpTestingController; - - - beforeAll(done => (async () => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - providers: [BasicControlGenerator, - AaiService, - {provide:FeatureFlagsService, useClass: MockFeatureFlagsService}, - {provide: NgRedux, useClass: MockAppStore}] - }); - await TestBed.compileComponents(); - - injector = getTestBed(); - service = injector.get(BasicControlGenerator); - httpMock = injector.get(HttpTestingController); - - })().then(done).catch(done.fail)); - - - test('getlegacyRegion with AAIAIC25 - isVisible true', () => { - const instance = {lcpCloudRegionId : 'AAIAIC25'}; - const legacyRegionControl: FormControlModel = service.getLegacyRegion(instance); - expect(legacyRegionControl.isVisible).toBeTruthy(); - }); - - test('getlegacyRegion without AAIAIC25 - isVisible false', () => { - const instance = {lcpCloudRegionId : 'olson3'}; - const legacyRegionControl: FormControlModel = service.getLegacyRegion(instance); - expect(legacyRegionControl.isVisible).toBeFalsy(); - }); - - test('sdn-preload checkbox is visible', () => { - const instance = {}; - const sdncPreload: FormControlModel = service.getSDNCControl(instance); - expect (sdncPreload.displayName).toEqual('SDN-C pre-load'); - expect (sdncPreload.value).toBeFalsy(); - }); - - test('given instance, get supp file from getSupplementaryFile ', () => { - const instance = {}; - const suppFileForInstance: FileFormControl = service.getSupplementaryFile(instance); - expect(suppFileForInstance.isVisible).toBeTruthy(); - expect(suppFileForInstance.hiddenFile.length).toBeGreaterThanOrEqual(1); - expect(suppFileForInstance.hiddenFile[0].validations[0].validatorName).toEqual("isFileTooBig"); - }); - - test('concatSupplementaryFile add SupplementaryFile control and hidden file', () => { - - //given - const instance = {}; - const controls = [service.getLegacyRegion(instance)]; - expect(controls).toHaveLength(1); - - //when - const result = service.concatSupplementaryFile(controls, instance); - - //then - expect(controls).toHaveLength(1); //original controls remain the same - - expect(result.map((control) => {return control.controlName})).toEqual([ - "legacyRegion", - "supplementaryFile", - "supplementaryFile_hidden", - "supplementaryFile_hidden_content" - ]); - }); - each([ - [null, false], - [{}, true] - ]). - test('retrieveInstanceIfUpdateMode returns %s if update mode is %s', (expected, isUpdateModalMode) => { - //given - const store= <any>{ - getState() { - return { - global: { - isUpdateModalMode - } - }}}; - const instance = {}; - - //when - let retrievedInstance = service.retrieveInstanceIfUpdateMode (store, instance); - - //then - expect(retrievedInstance).toEqual(expected); - - }); - -}); |