diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index 8105dfb..7f18e04 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -4,8 +4,13 @@ import {By} from '@angular/platform-browser'; import {RbUiComponentsModule} from '@inst-iot/bosch-angular-ui-components'; import {RouterTestingModule} from '@angular/router/testing'; import {LoginService} from './services/login.service'; +import {Router} from '@angular/router'; + +// TODO let loginServiceSpy: jasmine.SpyObj; +let routerServiceSpy: jasmine.SpyObj; +let windowServiceSpy: jasmine.SpyObj; describe('AppComponent', () => { let component: AppComponent; @@ -14,6 +19,8 @@ describe('AppComponent', () => { beforeEach(async(() => { const loginSpy = jasmine.createSpyObj('LoginService', ['login', 'canActivate']); + const routerSpy = jasmine.createSpyObj('Router', ['navigate', 'events']); + const windowSpy = jasmine.createSpyObj('Window', ['location', 'innerWidth', 'innerHeight', 'scroll']); TestBed.configureTestingModule({ declarations: [ AppComponent ], @@ -22,10 +29,15 @@ describe('AppComponent', () => { RouterTestingModule ], providers: [ - {provide: LoginService, useValue: loginSpy} + {provide: LoginService, useValue: loginSpy}, + {provide: Router, useValue: routerSpy}, + {provide: Window, useValue: windowSpy} ] }).compileComponents(); + loginServiceSpy = TestBed.inject(LoginService) as jasmine.SpyObj; + routerServiceSpy = TestBed.inject(Router) as jasmine.SpyObj; + windowServiceSpy = TestBed.inject(Window) as jasmine.SpyObj; })); beforeEach(() => { diff --git a/src/app/changelog/changelog.component.spec.ts b/src/app/changelog/changelog.component.spec.ts index a9ebfb6..f65f6b0 100644 --- a/src/app/changelog/changelog.component.spec.ts +++ b/src/app/changelog/changelog.component.spec.ts @@ -1,21 +1,44 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ChangelogComponent } from './changelog.component'; +import {ApiService} from '../services/api.service'; +import {ModalService, RbUiComponentsModule} from '@inst-iot/bosch-angular-ui-components'; +import {FormsModule} from '@angular/forms'; +import {ValidationService} from '../services/validation.service'; +import {DataService} from '../services/data.service'; + +// TODO + +let apiServiceSpy: jasmine.SpyObj; +let modalServiceSpy: jasmine.SpyObj; describe('ChangelogComponent', () => { let component: ChangelogComponent; let fixture: ComponentFixture; beforeEach(async(() => { + const apiSpy = jasmine.createSpyObj('ApiService', ['get']); + const modalSpy = jasmine.createSpyObj('ModalService', ['open']); + TestBed.configureTestingModule({ - declarations: [ ChangelogComponent ] + declarations: [ ChangelogComponent ], + imports: [ + ], + providers: [ + {provide: ApiService, useValue: apiSpy}, + {provide: ModalService, useValue: modalSpy} + ] }) .compileComponents(); + + apiServiceSpy = TestBed.inject(ApiService) as jasmine.SpyObj; + modalServiceSpy = TestBed.inject(ModalService) as jasmine.SpyObj; })); beforeEach(() => { fixture = TestBed.createComponent(ChangelogComponent); component = fixture.componentInstance; + component.ngOnInit(); fixture.detectChanges(); }); diff --git a/src/app/documentation-database/documentation-database.component.spec.ts b/src/app/documentation-database/documentation-database.component.spec.ts index 75dc273..5b8a177 100644 --- a/src/app/documentation-database/documentation-database.component.spec.ts +++ b/src/app/documentation-database/documentation-database.component.spec.ts @@ -2,6 +2,8 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { DocumentationDatabaseComponent } from './documentation-database.component'; +// TODO + describe('DocumentationDatabaseComponent', () => { let component: DocumentationDatabaseComponent; let fixture: ComponentFixture; @@ -16,6 +18,7 @@ describe('DocumentationDatabaseComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(DocumentationDatabaseComponent); component = fixture.componentInstance; + component.ngOnInit(); fixture.detectChanges(); }); diff --git a/src/app/documentation/documentation.component.spec.ts b/src/app/documentation/documentation.component.spec.ts index fec102e..680e304 100644 --- a/src/app/documentation/documentation.component.spec.ts +++ b/src/app/documentation/documentation.component.spec.ts @@ -1,6 +1,11 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { DocumentationComponent } from './documentation.component'; +import {RbUiComponentsModule} from '@inst-iot/bosch-angular-ui-components'; +import {FormsModule} from '@angular/forms'; +import {RbCustomInputsModule} from '../rb-custom-inputs/rb-custom-inputs.module'; + +// TODO describe('DocumentationComponent', () => { let component: DocumentationComponent; @@ -8,7 +13,10 @@ describe('DocumentationComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ DocumentationComponent ] + declarations: [ DocumentationComponent ], + imports: [ + RbCustomInputsModule + ] }) .compileComponents(); })); @@ -16,6 +24,7 @@ describe('DocumentationComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(DocumentationComponent); component = fixture.componentInstance; + component.ngOnInit(); fixture.detectChanges(); }); diff --git a/src/app/error/error.component.spec.ts b/src/app/error/error.component.spec.ts index 34f1cc0..d48f3f6 100644 --- a/src/app/error/error.component.spec.ts +++ b/src/app/error/error.component.spec.ts @@ -4,6 +4,8 @@ import { ErrorComponent } from './error.component'; import {ModalService, RbUiComponentsModule} from '@inst-iot/bosch-angular-ui-components'; import {By} from '@angular/platform-browser'; +// TODO + describe('ErrorComponent', () => { let component: ErrorComponent; let fixture: ComponentFixture; @@ -25,6 +27,7 @@ describe('ErrorComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(ErrorComponent); component = fixture.componentInstance; + component.ngOnInit(); fixture.detectChanges(); css = (selector) => fixture.debugElement.query(By.css(selector)).nativeElement; }); diff --git a/src/app/exists.pipe.spec.ts b/src/app/exists.pipe.spec.ts index 110c53c..2616a58 100644 --- a/src/app/exists.pipe.spec.ts +++ b/src/app/exists.pipe.spec.ts @@ -1,5 +1,7 @@ import { ExistsPipe } from './exists.pipe'; +// TODO + describe('ExistsPipe', () => { it('create an instance', () => { const pipe = new ExistsPipe(); diff --git a/src/app/home/home.component.spec.ts b/src/app/home/home.component.spec.ts index 061ca6e..5db4493 100644 --- a/src/app/home/home.component.spec.ts +++ b/src/app/home/home.component.spec.ts @@ -3,6 +3,8 @@ import { HomeComponent } from './home.component'; import {Component} from '@angular/core'; import {By} from '@angular/platform-browser'; +// TODO + @Component({selector: 'app-login', template: ''}) class LoginStubComponent {} @@ -23,6 +25,7 @@ describe('HomeComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(HomeComponent); component = fixture.componentInstance; + component.ngOnInit(); fixture.detectChanges(); }); diff --git a/src/app/img-magnifier/img-magnifier.component.spec.ts b/src/app/img-magnifier/img-magnifier.component.spec.ts index 753cad6..10ece39 100644 --- a/src/app/img-magnifier/img-magnifier.component.spec.ts +++ b/src/app/img-magnifier/img-magnifier.component.spec.ts @@ -1,21 +1,40 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ImgMagnifierComponent } from './img-magnifier.component'; +import {ApiService} from '../services/api.service'; +import {RbUiComponentsModule} from '@inst-iot/bosch-angular-ui-components'; +import {FormsModule} from '@angular/forms'; +import {ValidationService} from '../services/validation.service'; +import {DataService} from '../services/data.service'; + +// TODO + +let windowServiceSpy: jasmine.SpyObj; describe('ImgMagnifierComponent', () => { let component: ImgMagnifierComponent; let fixture: ComponentFixture; beforeEach(async(() => { + const windowSpy = jasmine.createSpyObj('Window', []); + TestBed.configureTestingModule({ - declarations: [ ImgMagnifierComponent ] + declarations: [ ImgMagnifierComponent ], + imports: [ + ], + providers: [ + {provide: Window, useValue: windowSpy} + ] }) .compileComponents(); + + windowServiceSpy = TestBed.inject(Window) as jasmine.SpyObj; })); beforeEach(() => { fixture = TestBed.createComponent(ImgMagnifierComponent); component = fixture.componentInstance; + component.ngOnInit(); fixture.detectChanges(); }); diff --git a/src/app/login/login.component.spec.ts b/src/app/login/login.component.spec.ts index 5922456..5a5ef85 100644 --- a/src/app/login/login.component.spec.ts +++ b/src/app/login/login.component.spec.ts @@ -7,6 +7,8 @@ import {By} from '@angular/platform-browser'; import {ValidateDirective} from '../validate.directive'; import {RbUiComponentsModule} from '@inst-iot/bosch-angular-ui-components'; +// TODO + let validationServiceSpy: jasmine.SpyObj; let loginServiceSpy: jasmine.SpyObj; diff --git a/src/app/models/user.model.spec.ts b/src/app/models/user.model.spec.ts index 3ba7e0b..c5ec2e7 100644 --- a/src/app/models/user.model.spec.ts +++ b/src/app/models/user.model.spec.ts @@ -1,6 +1,6 @@ import { UserModel } from './user.model'; -describe('User.Model', () => { +describe('UserModel', () => { it('should create an instance', () => { expect(new UserModel()).toBeTruthy(); }); diff --git a/src/app/object.pipe.spec.ts b/src/app/object.pipe.spec.ts index 5560af0..ee8c297 100644 --- a/src/app/object.pipe.spec.ts +++ b/src/app/object.pipe.spec.ts @@ -1,5 +1,7 @@ import { ObjectPipe } from './object.pipe'; +// TODO + describe('ObjectPipe', () => { it('create an instance', () => { const pipe = new ObjectPipe(); diff --git a/src/app/parameters.pipe.spec.ts b/src/app/parameters.pipe.spec.ts index 2dc7f21..e733aad 100644 --- a/src/app/parameters.pipe.spec.ts +++ b/src/app/parameters.pipe.spec.ts @@ -1,5 +1,7 @@ import { ParametersPipe } from './parameters.pipe'; +// TODO + describe('ParametersPipe', () => { it('create an instance', () => { const pipe = new ParametersPipe(); diff --git a/src/app/prediction/prediction.component.spec.ts b/src/app/prediction/prediction.component.spec.ts index 6259097..98b8640 100644 --- a/src/app/prediction/prediction.component.spec.ts +++ b/src/app/prediction/prediction.component.spec.ts @@ -1,21 +1,40 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { PredictionComponent } from './prediction.component'; +import {ApiService} from '../services/api.service'; +import {RbUiComponentsModule} from '@inst-iot/bosch-angular-ui-components'; +import {FormsModule} from '@angular/forms'; +import {ValidationService} from '../services/validation.service'; +import {DataService} from '../services/data.service'; + +// TODO + +let apiServiceSpy: jasmine.SpyObj; describe('PredictionComponent', () => { let component: PredictionComponent; let fixture: ComponentFixture; beforeEach(async(() => { + const apiSpy = jasmine.createSpyObj('ApiService', ['post']); + TestBed.configureTestingModule({ - declarations: [ PredictionComponent ] + declarations: [ PredictionComponent ], + imports: [ + ], + providers: [ + {provide: ApiService, useValue: apiSpy} + ] }) .compileComponents(); + + apiServiceSpy = TestBed.inject(ApiService) as jasmine.SpyObj; })); beforeEach(() => { fixture = TestBed.createComponent(PredictionComponent); component = fixture.componentInstance; + component.ngOnInit(); fixture.detectChanges(); }); diff --git a/src/app/rb-custom-inputs/rb-array-input/array-input-helper.service.spec.ts b/src/app/rb-custom-inputs/rb-array-input/array-input-helper.service.spec.ts index 9c60a48..0f80e61 100644 --- a/src/app/rb-custom-inputs/rb-array-input/array-input-helper.service.spec.ts +++ b/src/app/rb-custom-inputs/rb-array-input/array-input-helper.service.spec.ts @@ -2,6 +2,8 @@ import { TestBed } from '@angular/core/testing'; import { ArrayInputHelperService } from './array-input-helper.service'; +// TOdo + describe('ArrayInputHelperService', () => { let service: ArrayInputHelperService; diff --git a/src/app/rb-custom-inputs/rb-array-input/rb-array-input.component.spec.ts b/src/app/rb-custom-inputs/rb-array-input/rb-array-input.component.spec.ts index 1e0acad..75eca5e 100644 --- a/src/app/rb-custom-inputs/rb-array-input/rb-array-input.component.spec.ts +++ b/src/app/rb-custom-inputs/rb-array-input/rb-array-input.component.spec.ts @@ -16,6 +16,7 @@ describe('RbArrayInputComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(RbArrayInputComponent); component = fixture.componentInstance; + component.ngOnInit(); fixture.detectChanges(); }); diff --git a/src/app/rb-custom-inputs/rb-icon-button/rb-icon-button.component.spec.ts b/src/app/rb-custom-inputs/rb-icon-button/rb-icon-button.component.spec.ts index dad6730..28be0d9 100644 --- a/src/app/rb-custom-inputs/rb-icon-button/rb-icon-button.component.spec.ts +++ b/src/app/rb-custom-inputs/rb-icon-button/rb-icon-button.component.spec.ts @@ -2,6 +2,8 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { RbIconButtonComponent } from './rb-icon-button.component'; +// TODO + describe('RbIconButtonComponent', () => { let component: RbIconButtonComponent; let fixture: ComponentFixture; @@ -16,6 +18,7 @@ describe('RbIconButtonComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(RbIconButtonComponent); component = fixture.componentInstance; + component.ngOnInit(); fixture.detectChanges(); }); diff --git a/src/app/rb-custom-inputs/rb-table/rb-table.component.spec.ts b/src/app/rb-custom-inputs/rb-table/rb-table.component.spec.ts index c5bae98..6b0005d 100644 --- a/src/app/rb-custom-inputs/rb-table/rb-table.component.spec.ts +++ b/src/app/rb-custom-inputs/rb-table/rb-table.component.spec.ts @@ -2,6 +2,8 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { RbTableComponent } from './rb-table.component'; +// TODO + describe('RbTableComponent', () => { let component: RbTableComponent; let fixture: ComponentFixture; @@ -16,6 +18,7 @@ describe('RbTableComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(RbTableComponent); component = fixture.componentInstance; + component.ngOnInit(); fixture.detectChanges(); }); diff --git a/src/app/sample/sample.component.spec.ts b/src/app/sample/sample.component.spec.ts index 85ea267..c7ac4d4 100644 --- a/src/app/sample/sample.component.spec.ts +++ b/src/app/sample/sample.component.spec.ts @@ -1,27 +1,70 @@ -// import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -// -// import { SampleComponent } from './sample.component'; -// -// // TODO: tests -// -// describe('SampleComponent', () => { -// let component: SampleComponent; -// let fixture: ComponentFixture; -// -// beforeEach(async(() => { -// TestBed.configureTestingModule({ -// declarations: [ SampleComponent ] -// }) -// .compileComponents(); -// })); -// -// beforeEach(() => { -// fixture = TestBed.createComponent(SampleComponent); -// component = fixture.componentInstance; -// fixture.detectChanges(); -// }); -// -// it('should create', () => { -// expect(component).toBeTruthy(); -// }); -// }); +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { SampleComponent } from './sample.component'; +import {ApiService} from '../services/api.service'; +import {ValidationService} from '../services/validation.service'; +import {DataService} from '../services/data.service'; +import {ModalService, RbUiComponentsModule} from '@inst-iot/bosch-angular-ui-components'; +import {FormsModule} from '@angular/forms'; +import {ActivatedRoute, Router} from '@angular/router'; +import {AutocompleteService} from '../services/autocomplete.service'; + +// TODO + +let routerServiceSpy: jasmine.SpyObj; +let activatedRouteServiceSpy: jasmine.SpyObj; +let apiServiceSpy: jasmine.SpyObj; +let validationServiceSpy: jasmine.SpyObj; +let autocompleteServiceSpy: jasmine.SpyObj; +let modalServiceSpy: jasmine.SpyObj; +let dataServiceSpy: jasmine.SpyObj; + +describe('SampleComponent', () => { + let component: SampleComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + const routerSpy = jasmine.createSpyObj('Router', ['navigate']); + const activatedRouteSpy = jasmine.createSpyObj('ActivatedRoute', ['snapshot']); + const apiSpy = jasmine.createSpyObj('ApiService', ['post', 'put']); + const validationSpy = jasmine.createSpyObj('ValidationService', ['generate']); + const autocompleteSpy = jasmine.createSpyObj('AutocompleteService', []); + const modalSpy = jasmine.createSpyObj('ModalService', ['open']); + const dataSpy = jasmine.createSpyObj('DataService', ['load', 'idReload']); + + TestBed.configureTestingModule({ + declarations: [ SampleComponent ], + imports: [ + ], + providers: [ + {provide: Router, useValue: routerSpy}, + {provide: ActivatedRoute, useValue: activatedRouteSpy}, + {provide: ApiService, useValue: apiSpy}, + {provide: ValidationService, useValue: validationSpy}, + {provide: AutocompleteService, useValue: autocompleteSpy}, + {provide: ModalService, useValue: modalSpy}, + {provide: DataService, useValue: dataSpy} + ] + }) + .compileComponents(); + + routerServiceSpy = TestBed.inject(Router) as jasmine.SpyObj; + activatedRouteServiceSpy = TestBed.inject(ActivatedRoute) as jasmine.SpyObj; + apiServiceSpy = TestBed.inject(ApiService) as jasmine.SpyObj; + validationServiceSpy = TestBed.inject(ValidationService) as jasmine.SpyObj; + autocompleteServiceSpy = TestBed.inject(AutocompleteService) as jasmine.SpyObj; + modalServiceSpy = TestBed.inject(ModalService) as jasmine.SpyObj; + dataServiceSpy = TestBed.inject(DataService) as jasmine.SpyObj; + })); + + beforeEach(() => { + fixture = TestBed.createComponent(SampleComponent); + component = fixture.componentInstance; + component.ngOnInit(); + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/samples/samples.component.spec.ts b/src/app/samples/samples.component.spec.ts index d3ec677..722de64 100644 --- a/src/app/samples/samples.component.spec.ts +++ b/src/app/samples/samples.component.spec.ts @@ -1,27 +1,72 @@ -// import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -// -// import { SamplesComponent } from './samples.component'; -// -// // TODO: tests -// -// describe('SamplesComponent', () => { -// let component: SamplesComponent; -// let fixture: ComponentFixture; -// -// beforeEach(async(() => { -// TestBed.configureTestingModule({ -// declarations: [ SamplesComponent ] -// }) -// .compileComponents(); -// })); -// -// beforeEach(() => { -// fixture = TestBed.createComponent(SamplesComponent); -// component = fixture.componentInstance; -// fixture.detectChanges(); -// }); -// -// it('should create', () => { -// expect(component).toBeTruthy(); -// }); -// }); +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { SamplesComponent } from './samples.component'; +import {ApiService} from '../services/api.service'; +import {AutocompleteService} from '../services/autocomplete.service'; +import {DataService} from '../services/data.service'; +import {LoginService} from '../services/login.service'; +import {LocalStorageService} from 'angular-2-local-storage'; +import {ModalService} from '@inst-iot/bosch-angular-ui-components'; +import {ValidationService} from '../services/validation.service'; + +// TODO + +let apiServiceSpy: jasmine.SpyObj; +let autocompleteServiceSpy: jasmine.SpyObj; +let modalServiceSpy: jasmine.SpyObj; +let dataServiceSpy: jasmine.SpyObj; +let loginServiceSpy: jasmine.SpyObj; +let localStorageServiceSpy: jasmine.SpyObj; +let windowServiceSpy: jasmine.SpyObj; + + + +describe('SamplesComponent', () => { + let component: SamplesComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + const apiSpy = jasmine.createSpyObj('ApiService', ['post', 'put']); + const autocompleteSpy = jasmine.createSpyObj('AutocompleteService', []); + const loginSpy = jasmine.createSpyObj('LoginService', ['login', 'canActivate']); + const modalSpy = jasmine.createSpyObj('ModalService', ['open']); + const dataSpy = jasmine.createSpyObj('DataService', ['load', 'idReload']); + const localStorageSpy = jasmine.createSpyObj('LocalStorageService', ['set', 'remove']); + const windowSpy = jasmine.createSpyObj('Window', []); + + TestBed.configureTestingModule({ + declarations: [ SamplesComponent ], + imports: [ + ], + providers: [ + {provide: ApiService, useValue: apiSpy}, + {provide: AutocompleteService, useValue: autocompleteSpy}, + {provide: ModalService, useValue: modalSpy}, + {provide: DataService, useValue: dataSpy}, + {provide: LoginService, useValue: loginSpy}, + {provide: LocalStorageService, useValue: localStorageSpy}, + {provide: Window, useValue: windowSpy} + ] + }) + .compileComponents(); + + apiServiceSpy = TestBed.inject(ApiService) as jasmine.SpyObj; + autocompleteServiceSpy = TestBed.inject(AutocompleteService) as jasmine.SpyObj; + modalServiceSpy = TestBed.inject(ModalService) as jasmine.SpyObj; + dataServiceSpy = TestBed.inject(DataService) as jasmine.SpyObj; + loginServiceSpy = TestBed.inject(LoginService) as jasmine.SpyObj; + localStorageServiceSpy = TestBed.inject(LocalStorageService) as jasmine.SpyObj; + windowServiceSpy = TestBed.inject(Window) as jasmine.SpyObj; + })); + + beforeEach(() => { + fixture = TestBed.createComponent(SamplesComponent); + component = fixture.componentInstance; + component.ngOnInit(); + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/samples/samples.component.ts b/src/app/samples/samples.component.ts index 2b5f0b2..3230ac7 100644 --- a/src/app/samples/samples.component.ts +++ b/src/app/samples/samples.component.ts @@ -10,6 +10,8 @@ import {ModalService} from '@inst-iot/bosch-angular-ui-components'; import {DataService} from '../services/data.service'; import {LocalStorageService} from 'angular-2-local-storage'; +// TODO: turn off sort field + interface LoadSamplesOptions { toPage?: number; diff --git a/src/app/services/api.service.spec.ts b/src/app/services/api.service.spec.ts index 3782e9a..84af89d 100644 --- a/src/app/services/api.service.spec.ts +++ b/src/app/services/api.service.spec.ts @@ -10,6 +10,7 @@ let httpClientSpy: jasmine.SpyObj; let localStorageServiceSpy: jasmine.SpyObj; let modalServiceSpy: jasmine.SpyObj; +// TODO // TODO: test options describe('ApiService', () => { diff --git a/src/app/services/autocomplete.service.spec.ts b/src/app/services/autocomplete.service.spec.ts index ef9aae6..4b57bd1 100644 --- a/src/app/services/autocomplete.service.spec.ts +++ b/src/app/services/autocomplete.service.spec.ts @@ -2,6 +2,8 @@ import { TestBed } from '@angular/core/testing'; import { AutocompleteService } from './autocomplete.service'; +// TODO + let autocompleteService: AutocompleteService; describe('AutocompleteService', () => { diff --git a/src/app/services/data.service.spec.ts b/src/app/services/data.service.spec.ts index 38e8d9e..2fcc8f5 100644 --- a/src/app/services/data.service.spec.ts +++ b/src/app/services/data.service.spec.ts @@ -1,13 +1,30 @@ import { TestBed } from '@angular/core/testing'; import { DataService } from './data.service'; +import {ApiService} from './api.service'; +import {HttpClient} from '@angular/common/http'; +import {LocalStorageService} from 'angular-2-local-storage'; +import {ModalService} from '@inst-iot/bosch-angular-ui-components'; + +// TODO + +let apiServiceSpy: jasmine.SpyObj; + describe('DataService', () => { let service: DataService; beforeEach(() => { - TestBed.configureTestingModule({}); + const apiSpy = jasmine.createSpyObj('ApiService', ['post', 'put']); + + TestBed.configureTestingModule({ + providers: [ + {provide: ApiService, useValue: apiSpy} + ] + }); service = TestBed.inject(DataService); + + apiServiceSpy = TestBed.inject(ApiService) as jasmine.SpyObj; }); it('should be created', () => { diff --git a/src/app/services/login.service.spec.ts b/src/app/services/login.service.spec.ts index d7891fe..90474bb 100644 --- a/src/app/services/login.service.spec.ts +++ b/src/app/services/login.service.spec.ts @@ -4,6 +4,8 @@ import { LoginService } from './login.service'; import {LocalStorageService} from 'angular-2-local-storage'; import {ApiService} from './api.service'; +// TODO + let loginService: LoginService; let apiServiceSpy: jasmine.SpyObj; let localStorageServiceSpy: jasmine.SpyObj; diff --git a/src/app/services/validation.service.spec.ts b/src/app/services/validation.service.spec.ts index 67f8108..28c033c 100644 --- a/src/app/services/validation.service.spec.ts +++ b/src/app/services/validation.service.spec.ts @@ -1,6 +1,8 @@ import { TestBed } from '@angular/core/testing'; import { ValidationService } from './validation.service'; +// TODO + let validationService: ValidationService; describe('ValidationService', () => { diff --git a/src/app/settings/settings.component.spec.ts b/src/app/settings/settings.component.spec.ts index 91588f3..e0e6aff 100644 --- a/src/app/settings/settings.component.spec.ts +++ b/src/app/settings/settings.component.spec.ts @@ -1,21 +1,45 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { SettingsComponent } from './settings.component'; +import {ApiService} from '../services/api.service'; +import {LoginService} from '../services/login.service'; +import {Router} from '@angular/router'; + +// TODO + +let routerServiceSpy: jasmine.SpyObj; +let apiServiceSpy: jasmine.SpyObj; +let loginServiceSpy: jasmine.SpyObj; + describe('SettingsComponent', () => { let component: SettingsComponent; let fixture: ComponentFixture; beforeEach(async(() => { + const routerSpy = jasmine.createSpyObj('Router', ['navigate']); + const apiSpy = jasmine.createSpyObj('ApiService', ['post', 'put']); + const loginSpy = jasmine.createSpyObj('LoginService', ['login', 'canActivate']); + TestBed.configureTestingModule({ - declarations: [ SettingsComponent ] + declarations: [ SettingsComponent ], + providers: [ + {provide: Router, useValue: routerSpy}, + {provide: ApiService, useValue: apiSpy}, + {provide: LoginService, useValue: loginSpy}, + ] }) .compileComponents(); + + routerServiceSpy = TestBed.inject(Router) as jasmine.SpyObj; + apiServiceSpy = TestBed.inject(ApiService) as jasmine.SpyObj; + loginServiceSpy = TestBed.inject(LoginService) as jasmine.SpyObj; })); beforeEach(() => { fixture = TestBed.createComponent(SettingsComponent); component = fixture.componentInstance; + component.ngOnInit(); fixture.detectChanges(); }); diff --git a/src/app/templates/templates.component.spec.ts b/src/app/templates/templates.component.spec.ts index b5c63aa..d603e31 100644 --- a/src/app/templates/templates.component.spec.ts +++ b/src/app/templates/templates.component.spec.ts @@ -1,21 +1,51 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { TemplatesComponent } from './templates.component'; +import {LoginService} from '../services/login.service'; +import {ValidationService} from '../services/validation.service'; +import {ApiService} from '../services/api.service'; +import {DataService} from '../services/data.service'; +import {RbUiComponentsModule} from '@inst-iot/bosch-angular-ui-components'; +import {FormsModule} from '@angular/forms'; + +// TODO + +let apiServiceSpy: jasmine.SpyObj; +let validationServiceSpy: jasmine.SpyObj; +let dataServiceSpy: jasmine.SpyObj; describe('TemplatesComponent', () => { let component: TemplatesComponent; let fixture: ComponentFixture; beforeEach(async(() => { + const apiSpy = jasmine.createSpyObj('ApiService', ['post', 'put']); + const validationSpy = jasmine.createSpyObj('ValidationService', ['string', 'parameterName', 'parameterRange']); + const dataSpy = jasmine.createSpyObj('DataService', ['load', 'idReload']); + TestBed.configureTestingModule({ - declarations: [ TemplatesComponent ] + declarations: [ TemplatesComponent ], + imports: [ + RbUiComponentsModule, + FormsModule + ], + providers: [ + {provide: ApiService, useValue: apiSpy}, + {provide: ValidationService, useValue: validationSpy}, + {provide: DataService, useValue: dataSpy} + ] }) .compileComponents(); + + apiServiceSpy = TestBed.inject(ApiService) as jasmine.SpyObj; + validationServiceSpy = TestBed.inject(ValidationService) as jasmine.SpyObj; + dataServiceSpy = TestBed.inject(DataService) as jasmine.SpyObj; })); beforeEach(() => { fixture = TestBed.createComponent(TemplatesComponent); component = fixture.componentInstance; + component.ngOnInit(); fixture.detectChanges(); }); diff --git a/src/app/users/users.component.spec.ts b/src/app/users/users.component.spec.ts index 909b5ba..2842405 100644 --- a/src/app/users/users.component.spec.ts +++ b/src/app/users/users.component.spec.ts @@ -1,21 +1,45 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { UsersComponent } from './users.component'; +import {ApiService} from '../services/api.service'; +import {LoginService} from '../services/login.service'; +import {ModalService} from '@inst-iot/bosch-angular-ui-components'; + +// TODO + +let apiServiceSpy: jasmine.SpyObj; +let modalServiceSpy: jasmine.SpyObj; +let loginServiceSpy: jasmine.SpyObj; + describe('UsersComponent', () => { let component: UsersComponent; let fixture: ComponentFixture; beforeEach(async(() => { + const apiSpy = jasmine.createSpyObj('ApiService', ['post', 'put']); + const modalSpy = jasmine.createSpyObj('ModalService', ['open']); + const loginSpy = jasmine.createSpyObj('LoginService', ['login', 'canActivate']); + TestBed.configureTestingModule({ - declarations: [ UsersComponent ] + declarations: [ UsersComponent ], + providers: [ + {provide: ApiService, useValue: apiSpy}, + {provide: ModalService, useValue: modalSpy}, + {provide: LoginService, useValue: loginSpy}, + ] }) .compileComponents(); + + apiServiceSpy = TestBed.inject(ApiService) as jasmine.SpyObj; + modalServiceSpy = TestBed.inject(ModalService) as jasmine.SpyObj; + loginServiceSpy = TestBed.inject(LoginService) as jasmine.SpyObj; })); beforeEach(() => { fixture = TestBed.createComponent(UsersComponent); component = fixture.componentInstance; + component.ngOnInit(); fixture.detectChanges(); }); diff --git a/src/app/validate.directive.spec.ts b/src/app/validate.directive.spec.ts index 9489d0d..30b9b57 100644 --- a/src/app/validate.directive.spec.ts +++ b/src/app/validate.directive.spec.ts @@ -1,8 +1,14 @@ // import { ValidateDirective } from './validate.directive'; +// import {ValidationService} from './services/validation.service'; +// +// // TODO +// +// const validationSpy = {test: () => {}}; +// const validationServiceSpy: jasmine.SpyObj = spyOn(validationSpy, 'test'); // // describe('ValidateDirective', () => { // it('should create an instance', () => { -// const directive = new ValidateDirective(); +// const directive = new ValidateDirective(validationServiceSpy); // expect(directive).toBeTruthy(); // }); // });