diff options
Diffstat (limited to 'vid-webpack-master/src/app/shared/components/model-information/model-information.service.spec.ts')
-rw-r--r-- | vid-webpack-master/src/app/shared/components/model-information/model-information.service.spec.ts | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/vid-webpack-master/src/app/shared/components/model-information/model-information.service.spec.ts b/vid-webpack-master/src/app/shared/components/model-information/model-information.service.spec.ts index 418493f2b..3d80cffab 100644 --- a/vid-webpack-master/src/app/shared/components/model-information/model-information.service.spec.ts +++ b/vid-webpack-master/src/app/shared/components/model-information/model-information.service.spec.ts @@ -1,15 +1,32 @@ import {ModelInformationService} from "./model-information.service"; import {ModelInformationItem} from "./model-information.component"; +import {HttpClientTestingModule, HttpTestingController} from "@angular/common/http/testing"; +import {getTestBed, TestBed} from "@angular/core/testing"; describe('ModelInformationService', () => { - let underTest:ModelInformationService; + let injector; + let service: ModelInformationService; + let httpMock: HttpTestingController; + + + beforeAll(done => (async () => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], + providers: [ + ModelInformationService + ] + }); + await TestBed.compileComponents(); + + injector = getTestBed(); + service = injector.get(ModelInformationService); + httpMock = injector.get(HttpTestingController); + + })().then(done).catch(done.fail)); - beforeEach(() => { - underTest = new ModelInformationService(); - }); test('when call to filterModelItems then items with empty values are filtered', () =>{ - expect(underTest.filterModelItems([ + expect(service.filterModelItems([ ModelInformationItem.createInstance("emptyValue", ""), ModelInformationItem.createInstance("nullValue", null), ModelInformationItem.createInstance("undefinedValue", undefined), @@ -20,13 +37,14 @@ describe('ModelInformationService', () => { test('when call to filterModelItems then mandatory items with empty values are not filtered', () =>{ const mandatoryItem:ModelInformationItem = new ModelInformationItem("a", "b", [""], "c", true); - expect(underTest.filterModelItems([mandatoryItem])).toEqual([mandatoryItem]); + expect(service.filterModelItems([mandatoryItem])).toEqual([mandatoryItem]); }); test('when call to filterModelItems then items with values are not filtered', () =>{ - expect(underTest.filterModelItems([ + expect(service.filterModelItems([ ModelInformationItem.createInstance("withString", "a"), ModelInformationItem.createInstance("withNumber", 1), ])).toHaveLength(2); }); + }); |