started testing

This commit is contained in:
VLE2FE 2020-08-16 20:01:56 +02:00
parent f07c3be23a
commit 9197e8a187
29 changed files with 371 additions and 65 deletions

View File

@ -4,8 +4,13 @@ import {By} from '@angular/platform-browser';
import {RbUiComponentsModule} from '@inst-iot/bosch-angular-ui-components'; import {RbUiComponentsModule} from '@inst-iot/bosch-angular-ui-components';
import {RouterTestingModule} from '@angular/router/testing'; import {RouterTestingModule} from '@angular/router/testing';
import {LoginService} from './services/login.service'; import {LoginService} from './services/login.service';
import {Router} from '@angular/router';
// TODO
let loginServiceSpy: jasmine.SpyObj<LoginService>; let loginServiceSpy: jasmine.SpyObj<LoginService>;
let routerServiceSpy: jasmine.SpyObj<Router>;
let windowServiceSpy: jasmine.SpyObj<Window>;
describe('AppComponent', () => { describe('AppComponent', () => {
let component: AppComponent; let component: AppComponent;
@ -14,6 +19,8 @@ describe('AppComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
const loginSpy = jasmine.createSpyObj('LoginService', ['login', 'canActivate']); 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({ TestBed.configureTestingModule({
declarations: [ AppComponent ], declarations: [ AppComponent ],
@ -22,10 +29,15 @@ describe('AppComponent', () => {
RouterTestingModule RouterTestingModule
], ],
providers: [ providers: [
{provide: LoginService, useValue: loginSpy} {provide: LoginService, useValue: loginSpy},
{provide: Router, useValue: routerSpy},
{provide: Window, useValue: windowSpy}
] ]
}).compileComponents(); }).compileComponents();
loginServiceSpy = TestBed.inject(LoginService) as jasmine.SpyObj<LoginService>; loginServiceSpy = TestBed.inject(LoginService) as jasmine.SpyObj<LoginService>;
routerServiceSpy = TestBed.inject(Router) as jasmine.SpyObj<Router>;
windowServiceSpy = TestBed.inject(Window) as jasmine.SpyObj<Window>;
})); }));
beforeEach(() => { beforeEach(() => {

View File

@ -1,21 +1,44 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ChangelogComponent } from './changelog.component'; 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<ApiService>;
let modalServiceSpy: jasmine.SpyObj<ModalService>;
describe('ChangelogComponent', () => { describe('ChangelogComponent', () => {
let component: ChangelogComponent; let component: ChangelogComponent;
let fixture: ComponentFixture<ChangelogComponent>; let fixture: ComponentFixture<ChangelogComponent>;
beforeEach(async(() => { beforeEach(async(() => {
const apiSpy = jasmine.createSpyObj('ApiService', ['get']);
const modalSpy = jasmine.createSpyObj('ModalService', ['open']);
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ ChangelogComponent ] declarations: [ ChangelogComponent ],
imports: [
],
providers: [
{provide: ApiService, useValue: apiSpy},
{provide: ModalService, useValue: modalSpy}
]
}) })
.compileComponents(); .compileComponents();
apiServiceSpy = TestBed.inject(ApiService) as jasmine.SpyObj<ApiService>;
modalServiceSpy = TestBed.inject(ModalService) as jasmine.SpyObj<ModalService>;
})); }));
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(ChangelogComponent); fixture = TestBed.createComponent(ChangelogComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
component.ngOnInit();
fixture.detectChanges(); fixture.detectChanges();
}); });

View File

@ -2,6 +2,8 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { DocumentationDatabaseComponent } from './documentation-database.component'; import { DocumentationDatabaseComponent } from './documentation-database.component';
// TODO
describe('DocumentationDatabaseComponent', () => { describe('DocumentationDatabaseComponent', () => {
let component: DocumentationDatabaseComponent; let component: DocumentationDatabaseComponent;
let fixture: ComponentFixture<DocumentationDatabaseComponent>; let fixture: ComponentFixture<DocumentationDatabaseComponent>;
@ -16,6 +18,7 @@ describe('DocumentationDatabaseComponent', () => {
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(DocumentationDatabaseComponent); fixture = TestBed.createComponent(DocumentationDatabaseComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
component.ngOnInit();
fixture.detectChanges(); fixture.detectChanges();
}); });

View File

@ -1,6 +1,11 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { DocumentationComponent } from './documentation.component'; 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', () => { describe('DocumentationComponent', () => {
let component: DocumentationComponent; let component: DocumentationComponent;
@ -8,7 +13,10 @@ describe('DocumentationComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ DocumentationComponent ] declarations: [ DocumentationComponent ],
imports: [
RbCustomInputsModule
]
}) })
.compileComponents(); .compileComponents();
})); }));
@ -16,6 +24,7 @@ describe('DocumentationComponent', () => {
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(DocumentationComponent); fixture = TestBed.createComponent(DocumentationComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
component.ngOnInit();
fixture.detectChanges(); fixture.detectChanges();
}); });

View File

@ -4,6 +4,8 @@ import { ErrorComponent } from './error.component';
import {ModalService, RbUiComponentsModule} from '@inst-iot/bosch-angular-ui-components'; import {ModalService, RbUiComponentsModule} from '@inst-iot/bosch-angular-ui-components';
import {By} from '@angular/platform-browser'; import {By} from '@angular/platform-browser';
// TODO
describe('ErrorComponent', () => { describe('ErrorComponent', () => {
let component: ErrorComponent; let component: ErrorComponent;
let fixture: ComponentFixture<ErrorComponent>; let fixture: ComponentFixture<ErrorComponent>;
@ -25,6 +27,7 @@ describe('ErrorComponent', () => {
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(ErrorComponent); fixture = TestBed.createComponent(ErrorComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
component.ngOnInit();
fixture.detectChanges(); fixture.detectChanges();
css = (selector) => fixture.debugElement.query(By.css(selector)).nativeElement; css = (selector) => fixture.debugElement.query(By.css(selector)).nativeElement;
}); });

View File

@ -1,5 +1,7 @@
import { ExistsPipe } from './exists.pipe'; import { ExistsPipe } from './exists.pipe';
// TODO
describe('ExistsPipe', () => { describe('ExistsPipe', () => {
it('create an instance', () => { it('create an instance', () => {
const pipe = new ExistsPipe(); const pipe = new ExistsPipe();

View File

@ -3,6 +3,8 @@ import { HomeComponent } from './home.component';
import {Component} from '@angular/core'; import {Component} from '@angular/core';
import {By} from '@angular/platform-browser'; import {By} from '@angular/platform-browser';
// TODO
@Component({selector: 'app-login', template: ''}) @Component({selector: 'app-login', template: ''})
class LoginStubComponent {} class LoginStubComponent {}
@ -23,6 +25,7 @@ describe('HomeComponent', () => {
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(HomeComponent); fixture = TestBed.createComponent(HomeComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
component.ngOnInit();
fixture.detectChanges(); fixture.detectChanges();
}); });

View File

@ -1,21 +1,40 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ImgMagnifierComponent } from './img-magnifier.component'; 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<Window>;
describe('ImgMagnifierComponent', () => { describe('ImgMagnifierComponent', () => {
let component: ImgMagnifierComponent; let component: ImgMagnifierComponent;
let fixture: ComponentFixture<ImgMagnifierComponent>; let fixture: ComponentFixture<ImgMagnifierComponent>;
beforeEach(async(() => { beforeEach(async(() => {
const windowSpy = jasmine.createSpyObj('Window', []);
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ ImgMagnifierComponent ] declarations: [ ImgMagnifierComponent ],
imports: [
],
providers: [
{provide: Window, useValue: windowSpy}
]
}) })
.compileComponents(); .compileComponents();
windowServiceSpy = TestBed.inject(Window) as jasmine.SpyObj<Window>;
})); }));
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(ImgMagnifierComponent); fixture = TestBed.createComponent(ImgMagnifierComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
component.ngOnInit();
fixture.detectChanges(); fixture.detectChanges();
}); });

View File

@ -7,6 +7,8 @@ import {By} from '@angular/platform-browser';
import {ValidateDirective} from '../validate.directive'; import {ValidateDirective} from '../validate.directive';
import {RbUiComponentsModule} from '@inst-iot/bosch-angular-ui-components'; import {RbUiComponentsModule} from '@inst-iot/bosch-angular-ui-components';
// TODO
let validationServiceSpy: jasmine.SpyObj<ValidationService>; let validationServiceSpy: jasmine.SpyObj<ValidationService>;
let loginServiceSpy: jasmine.SpyObj<LoginService>; let loginServiceSpy: jasmine.SpyObj<LoginService>;

View File

@ -1,6 +1,6 @@
import { UserModel } from './user.model'; import { UserModel } from './user.model';
describe('User.Model', () => { describe('UserModel', () => {
it('should create an instance', () => { it('should create an instance', () => {
expect(new UserModel()).toBeTruthy(); expect(new UserModel()).toBeTruthy();
}); });

View File

@ -1,5 +1,7 @@
import { ObjectPipe } from './object.pipe'; import { ObjectPipe } from './object.pipe';
// TODO
describe('ObjectPipe', () => { describe('ObjectPipe', () => {
it('create an instance', () => { it('create an instance', () => {
const pipe = new ObjectPipe(); const pipe = new ObjectPipe();

View File

@ -1,5 +1,7 @@
import { ParametersPipe } from './parameters.pipe'; import { ParametersPipe } from './parameters.pipe';
// TODO
describe('ParametersPipe', () => { describe('ParametersPipe', () => {
it('create an instance', () => { it('create an instance', () => {
const pipe = new ParametersPipe(); const pipe = new ParametersPipe();

View File

@ -1,21 +1,40 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { PredictionComponent } from './prediction.component'; 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<ApiService>;
describe('PredictionComponent', () => { describe('PredictionComponent', () => {
let component: PredictionComponent; let component: PredictionComponent;
let fixture: ComponentFixture<PredictionComponent>; let fixture: ComponentFixture<PredictionComponent>;
beforeEach(async(() => { beforeEach(async(() => {
const apiSpy = jasmine.createSpyObj('ApiService', ['post']);
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ PredictionComponent ] declarations: [ PredictionComponent ],
imports: [
],
providers: [
{provide: ApiService, useValue: apiSpy}
]
}) })
.compileComponents(); .compileComponents();
apiServiceSpy = TestBed.inject(ApiService) as jasmine.SpyObj<ApiService>;
})); }));
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(PredictionComponent); fixture = TestBed.createComponent(PredictionComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
component.ngOnInit();
fixture.detectChanges(); fixture.detectChanges();
}); });

View File

@ -2,6 +2,8 @@ import { TestBed } from '@angular/core/testing';
import { ArrayInputHelperService } from './array-input-helper.service'; import { ArrayInputHelperService } from './array-input-helper.service';
// TOdo
describe('ArrayInputHelperService', () => { describe('ArrayInputHelperService', () => {
let service: ArrayInputHelperService; let service: ArrayInputHelperService;

View File

@ -16,6 +16,7 @@ describe('RbArrayInputComponent', () => {
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(RbArrayInputComponent); fixture = TestBed.createComponent(RbArrayInputComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
component.ngOnInit();
fixture.detectChanges(); fixture.detectChanges();
}); });

View File

@ -2,6 +2,8 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RbIconButtonComponent } from './rb-icon-button.component'; import { RbIconButtonComponent } from './rb-icon-button.component';
// TODO
describe('RbIconButtonComponent', () => { describe('RbIconButtonComponent', () => {
let component: RbIconButtonComponent; let component: RbIconButtonComponent;
let fixture: ComponentFixture<RbIconButtonComponent>; let fixture: ComponentFixture<RbIconButtonComponent>;
@ -16,6 +18,7 @@ describe('RbIconButtonComponent', () => {
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(RbIconButtonComponent); fixture = TestBed.createComponent(RbIconButtonComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
component.ngOnInit();
fixture.detectChanges(); fixture.detectChanges();
}); });

View File

@ -2,6 +2,8 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RbTableComponent } from './rb-table.component'; import { RbTableComponent } from './rb-table.component';
// TODO
describe('RbTableComponent', () => { describe('RbTableComponent', () => {
let component: RbTableComponent; let component: RbTableComponent;
let fixture: ComponentFixture<RbTableComponent>; let fixture: ComponentFixture<RbTableComponent>;
@ -16,6 +18,7 @@ describe('RbTableComponent', () => {
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(RbTableComponent); fixture = TestBed.createComponent(RbTableComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
component.ngOnInit();
fixture.detectChanges(); fixture.detectChanges();
}); });

View File

@ -1,27 +1,70 @@
// import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
//
// import { SampleComponent } from './sample.component'; import { SampleComponent } from './sample.component';
// import {ApiService} from '../services/api.service';
// // TODO: tests import {ValidationService} from '../services/validation.service';
// import {DataService} from '../services/data.service';
// describe('SampleComponent', () => { import {ModalService, RbUiComponentsModule} from '@inst-iot/bosch-angular-ui-components';
// let component: SampleComponent; import {FormsModule} from '@angular/forms';
// let fixture: ComponentFixture<SampleComponent>; import {ActivatedRoute, Router} from '@angular/router';
// import {AutocompleteService} from '../services/autocomplete.service';
// beforeEach(async(() => {
// TestBed.configureTestingModule({ // TODO
// declarations: [ SampleComponent ]
// }) let routerServiceSpy: jasmine.SpyObj<Router>;
// .compileComponents(); let activatedRouteServiceSpy: jasmine.SpyObj<ActivatedRoute>;
// })); let apiServiceSpy: jasmine.SpyObj<ApiService>;
// let validationServiceSpy: jasmine.SpyObj<ValidationService>;
// beforeEach(() => { let autocompleteServiceSpy: jasmine.SpyObj<AutocompleteService>;
// fixture = TestBed.createComponent(SampleComponent); let modalServiceSpy: jasmine.SpyObj<ModalService>;
// component = fixture.componentInstance; let dataServiceSpy: jasmine.SpyObj<DataService>;
// fixture.detectChanges();
// }); describe('SampleComponent', () => {
// let component: SampleComponent;
// it('should create', () => { let fixture: ComponentFixture<SampleComponent>;
// expect(component).toBeTruthy();
// }); 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<Router>;
activatedRouteServiceSpy = TestBed.inject(ActivatedRoute) as jasmine.SpyObj<ActivatedRoute>;
apiServiceSpy = TestBed.inject(ApiService) as jasmine.SpyObj<ApiService>;
validationServiceSpy = TestBed.inject(ValidationService) as jasmine.SpyObj<ValidationService>;
autocompleteServiceSpy = TestBed.inject(AutocompleteService) as jasmine.SpyObj<AutocompleteService>;
modalServiceSpy = TestBed.inject(ModalService) as jasmine.SpyObj<ModalService>;
dataServiceSpy = TestBed.inject(DataService) as jasmine.SpyObj<DataService>;
}));
beforeEach(() => {
fixture = TestBed.createComponent(SampleComponent);
component = fixture.componentInstance;
component.ngOnInit();
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -1,27 +1,72 @@
// import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
//
// import { SamplesComponent } from './samples.component'; import { SamplesComponent } from './samples.component';
// import {ApiService} from '../services/api.service';
// // TODO: tests import {AutocompleteService} from '../services/autocomplete.service';
// import {DataService} from '../services/data.service';
// describe('SamplesComponent', () => { import {LoginService} from '../services/login.service';
// let component: SamplesComponent; import {LocalStorageService} from 'angular-2-local-storage';
// let fixture: ComponentFixture<SamplesComponent>; import {ModalService} from '@inst-iot/bosch-angular-ui-components';
// import {ValidationService} from '../services/validation.service';
// beforeEach(async(() => {
// TestBed.configureTestingModule({ // TODO
// declarations: [ SamplesComponent ]
// }) let apiServiceSpy: jasmine.SpyObj<ApiService>;
// .compileComponents(); let autocompleteServiceSpy: jasmine.SpyObj<AutocompleteService>;
// })); let modalServiceSpy: jasmine.SpyObj<ModalService>;
// let dataServiceSpy: jasmine.SpyObj<DataService>;
// beforeEach(() => { let loginServiceSpy: jasmine.SpyObj<LoginService>;
// fixture = TestBed.createComponent(SamplesComponent); let localStorageServiceSpy: jasmine.SpyObj<LocalStorageService>;
// component = fixture.componentInstance; let windowServiceSpy: jasmine.SpyObj<Window>;
// fixture.detectChanges();
// });
//
// it('should create', () => { describe('SamplesComponent', () => {
// expect(component).toBeTruthy(); let component: SamplesComponent;
// }); let fixture: ComponentFixture<SamplesComponent>;
// });
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<ApiService>;
autocompleteServiceSpy = TestBed.inject(AutocompleteService) as jasmine.SpyObj<AutocompleteService>;
modalServiceSpy = TestBed.inject(ModalService) as jasmine.SpyObj<ModalService>;
dataServiceSpy = TestBed.inject(DataService) as jasmine.SpyObj<DataService>;
loginServiceSpy = TestBed.inject(LoginService) as jasmine.SpyObj<LoginService>;
localStorageServiceSpy = TestBed.inject(LocalStorageService) as jasmine.SpyObj<LocalStorageService>;
windowServiceSpy = TestBed.inject(Window) as jasmine.SpyObj<Window>;
}));
beforeEach(() => {
fixture = TestBed.createComponent(SamplesComponent);
component = fixture.componentInstance;
component.ngOnInit();
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -10,6 +10,8 @@ import {ModalService} from '@inst-iot/bosch-angular-ui-components';
import {DataService} from '../services/data.service'; import {DataService} from '../services/data.service';
import {LocalStorageService} from 'angular-2-local-storage'; import {LocalStorageService} from 'angular-2-local-storage';
// TODO: turn off sort field
interface LoadSamplesOptions { interface LoadSamplesOptions {
toPage?: number; toPage?: number;

View File

@ -10,6 +10,7 @@ let httpClientSpy: jasmine.SpyObj<HttpClient>;
let localStorageServiceSpy: jasmine.SpyObj<LocalStorageService>; let localStorageServiceSpy: jasmine.SpyObj<LocalStorageService>;
let modalServiceSpy: jasmine.SpyObj<ModalService>; let modalServiceSpy: jasmine.SpyObj<ModalService>;
// TODO
// TODO: test options // TODO: test options
describe('ApiService', () => { describe('ApiService', () => {

View File

@ -2,6 +2,8 @@ import { TestBed } from '@angular/core/testing';
import { AutocompleteService } from './autocomplete.service'; import { AutocompleteService } from './autocomplete.service';
// TODO
let autocompleteService: AutocompleteService; let autocompleteService: AutocompleteService;
describe('AutocompleteService', () => { describe('AutocompleteService', () => {

View File

@ -1,13 +1,30 @@
import { TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { DataService } from './data.service'; 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<ApiService>;
describe('DataService', () => { describe('DataService', () => {
let service: DataService; let service: DataService;
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({}); const apiSpy = jasmine.createSpyObj('ApiService', ['post', 'put']);
TestBed.configureTestingModule({
providers: [
{provide: ApiService, useValue: apiSpy}
]
});
service = TestBed.inject(DataService); service = TestBed.inject(DataService);
apiServiceSpy = TestBed.inject(ApiService) as jasmine.SpyObj<ApiService>;
}); });
it('should be created', () => { it('should be created', () => {

View File

@ -4,6 +4,8 @@ import { LoginService } from './login.service';
import {LocalStorageService} from 'angular-2-local-storage'; import {LocalStorageService} from 'angular-2-local-storage';
import {ApiService} from './api.service'; import {ApiService} from './api.service';
// TODO
let loginService: LoginService; let loginService: LoginService;
let apiServiceSpy: jasmine.SpyObj<ApiService>; let apiServiceSpy: jasmine.SpyObj<ApiService>;
let localStorageServiceSpy: jasmine.SpyObj<LocalStorageService>; let localStorageServiceSpy: jasmine.SpyObj<LocalStorageService>;

View File

@ -1,6 +1,8 @@
import { TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { ValidationService } from './validation.service'; import { ValidationService } from './validation.service';
// TODO
let validationService: ValidationService; let validationService: ValidationService;
describe('ValidationService', () => { describe('ValidationService', () => {

View File

@ -1,21 +1,45 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { SettingsComponent } from './settings.component'; 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<Router>;
let apiServiceSpy: jasmine.SpyObj<ApiService>;
let loginServiceSpy: jasmine.SpyObj<LoginService>;
describe('SettingsComponent', () => { describe('SettingsComponent', () => {
let component: SettingsComponent; let component: SettingsComponent;
let fixture: ComponentFixture<SettingsComponent>; let fixture: ComponentFixture<SettingsComponent>;
beforeEach(async(() => { beforeEach(async(() => {
const routerSpy = jasmine.createSpyObj('Router', ['navigate']);
const apiSpy = jasmine.createSpyObj('ApiService', ['post', 'put']);
const loginSpy = jasmine.createSpyObj('LoginService', ['login', 'canActivate']);
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ SettingsComponent ] declarations: [ SettingsComponent ],
providers: [
{provide: Router, useValue: routerSpy},
{provide: ApiService, useValue: apiSpy},
{provide: LoginService, useValue: loginSpy},
]
}) })
.compileComponents(); .compileComponents();
routerServiceSpy = TestBed.inject(Router) as jasmine.SpyObj<Router>;
apiServiceSpy = TestBed.inject(ApiService) as jasmine.SpyObj<ApiService>;
loginServiceSpy = TestBed.inject(LoginService) as jasmine.SpyObj<LoginService>;
})); }));
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(SettingsComponent); fixture = TestBed.createComponent(SettingsComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
component.ngOnInit();
fixture.detectChanges(); fixture.detectChanges();
}); });

View File

@ -1,21 +1,51 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { TemplatesComponent } from './templates.component'; 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<ApiService>;
let validationServiceSpy: jasmine.SpyObj<ValidationService>;
let dataServiceSpy: jasmine.SpyObj<DataService>;
describe('TemplatesComponent', () => { describe('TemplatesComponent', () => {
let component: TemplatesComponent; let component: TemplatesComponent;
let fixture: ComponentFixture<TemplatesComponent>; let fixture: ComponentFixture<TemplatesComponent>;
beforeEach(async(() => { 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({ TestBed.configureTestingModule({
declarations: [ TemplatesComponent ] declarations: [ TemplatesComponent ],
imports: [
RbUiComponentsModule,
FormsModule
],
providers: [
{provide: ApiService, useValue: apiSpy},
{provide: ValidationService, useValue: validationSpy},
{provide: DataService, useValue: dataSpy}
]
}) })
.compileComponents(); .compileComponents();
apiServiceSpy = TestBed.inject(ApiService) as jasmine.SpyObj<ApiService>;
validationServiceSpy = TestBed.inject(ValidationService) as jasmine.SpyObj<ValidationService>;
dataServiceSpy = TestBed.inject(DataService) as jasmine.SpyObj<DataService>;
})); }));
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(TemplatesComponent); fixture = TestBed.createComponent(TemplatesComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
component.ngOnInit();
fixture.detectChanges(); fixture.detectChanges();
}); });

View File

@ -1,21 +1,45 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { UsersComponent } from './users.component'; 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<ApiService>;
let modalServiceSpy: jasmine.SpyObj<ModalService>;
let loginServiceSpy: jasmine.SpyObj<LoginService>;
describe('UsersComponent', () => { describe('UsersComponent', () => {
let component: UsersComponent; let component: UsersComponent;
let fixture: ComponentFixture<UsersComponent>; let fixture: ComponentFixture<UsersComponent>;
beforeEach(async(() => { beforeEach(async(() => {
const apiSpy = jasmine.createSpyObj('ApiService', ['post', 'put']);
const modalSpy = jasmine.createSpyObj('ModalService', ['open']);
const loginSpy = jasmine.createSpyObj('LoginService', ['login', 'canActivate']);
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ UsersComponent ] declarations: [ UsersComponent ],
providers: [
{provide: ApiService, useValue: apiSpy},
{provide: ModalService, useValue: modalSpy},
{provide: LoginService, useValue: loginSpy},
]
}) })
.compileComponents(); .compileComponents();
apiServiceSpy = TestBed.inject(ApiService) as jasmine.SpyObj<ApiService>;
modalServiceSpy = TestBed.inject(ModalService) as jasmine.SpyObj<ModalService>;
loginServiceSpy = TestBed.inject(LoginService) as jasmine.SpyObj<LoginService>;
})); }));
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(UsersComponent); fixture = TestBed.createComponent(UsersComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
component.ngOnInit();
fixture.detectChanges(); fixture.detectChanges();
}); });

View File

@ -1,8 +1,14 @@
// import { ValidateDirective } from './validate.directive'; // import { ValidateDirective } from './validate.directive';
// import {ValidationService} from './services/validation.service';
//
// // TODO
//
// const validationSpy = {test: () => {}};
// const validationServiceSpy: jasmine.SpyObj<any> = spyOn(validationSpy, 'test');
// //
// describe('ValidateDirective', () => { // describe('ValidateDirective', () => {
// it('should create an instance', () => { // it('should create an instance', () => {
// const directive = new ValidateDirective(); // const directive = new ValidateDirective(validationServiceSpy);
// expect(directive).toBeTruthy(); // expect(directive).toBeTruthy();
// }); // });
// }); // });