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 {RouterTestingModule} from '@angular/router/testing';
import {LoginService} from './services/login.service';
import {Router} from '@angular/router';
// TODO
let loginServiceSpy: jasmine.SpyObj<LoginService>;
let routerServiceSpy: jasmine.SpyObj<Router>;
let windowServiceSpy: jasmine.SpyObj<Window>;
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<LoginService>;
routerServiceSpy = TestBed.inject(Router) as jasmine.SpyObj<Router>;
windowServiceSpy = TestBed.inject(Window) as jasmine.SpyObj<Window>;
}));
beforeEach(() => {

View File

@ -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<ApiService>;
let modalServiceSpy: jasmine.SpyObj<ModalService>;
describe('ChangelogComponent', () => {
let component: ChangelogComponent;
let fixture: ComponentFixture<ChangelogComponent>;
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<ApiService>;
modalServiceSpy = TestBed.inject(ModalService) as jasmine.SpyObj<ModalService>;
}));
beforeEach(() => {
fixture = TestBed.createComponent(ChangelogComponent);
component = fixture.componentInstance;
component.ngOnInit();
fixture.detectChanges();
});

View File

@ -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<DocumentationDatabaseComponent>;
@ -16,6 +18,7 @@ describe('DocumentationDatabaseComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(DocumentationDatabaseComponent);
component = fixture.componentInstance;
component.ngOnInit();
fixture.detectChanges();
});

View File

@ -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();
});

View File

@ -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<ErrorComponent>;
@ -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;
});

View File

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

View File

@ -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();
});

View File

@ -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<Window>;
describe('ImgMagnifierComponent', () => {
let component: ImgMagnifierComponent;
let fixture: ComponentFixture<ImgMagnifierComponent>;
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<Window>;
}));
beforeEach(() => {
fixture = TestBed.createComponent(ImgMagnifierComponent);
component = fixture.componentInstance;
component.ngOnInit();
fixture.detectChanges();
});

View File

@ -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<ValidationService>;
let loginServiceSpy: jasmine.SpyObj<LoginService>;

View File

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

View File

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

View File

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

View File

@ -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<ApiService>;
describe('PredictionComponent', () => {
let component: PredictionComponent;
let fixture: ComponentFixture<PredictionComponent>;
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<ApiService>;
}));
beforeEach(() => {
fixture = TestBed.createComponent(PredictionComponent);
component = fixture.componentInstance;
component.ngOnInit();
fixture.detectChanges();
});

View File

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

View File

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

View File

@ -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<RbIconButtonComponent>;
@ -16,6 +18,7 @@ describe('RbIconButtonComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(RbIconButtonComponent);
component = fixture.componentInstance;
component.ngOnInit();
fixture.detectChanges();
});

View File

@ -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<RbTableComponent>;
@ -16,6 +18,7 @@ describe('RbTableComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(RbTableComponent);
component = fixture.componentInstance;
component.ngOnInit();
fixture.detectChanges();
});

View File

@ -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<SampleComponent>;
//
// 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<Router>;
let activatedRouteServiceSpy: jasmine.SpyObj<ActivatedRoute>;
let apiServiceSpy: jasmine.SpyObj<ApiService>;
let validationServiceSpy: jasmine.SpyObj<ValidationService>;
let autocompleteServiceSpy: jasmine.SpyObj<AutocompleteService>;
let modalServiceSpy: jasmine.SpyObj<ModalService>;
let dataServiceSpy: jasmine.SpyObj<DataService>;
describe('SampleComponent', () => {
let component: SampleComponent;
let fixture: ComponentFixture<SampleComponent>;
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 { SamplesComponent } from './samples.component';
//
// // TODO: tests
//
// describe('SamplesComponent', () => {
// let component: SamplesComponent;
// let fixture: ComponentFixture<SamplesComponent>;
//
// 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<ApiService>;
let autocompleteServiceSpy: jasmine.SpyObj<AutocompleteService>;
let modalServiceSpy: jasmine.SpyObj<ModalService>;
let dataServiceSpy: jasmine.SpyObj<DataService>;
let loginServiceSpy: jasmine.SpyObj<LoginService>;
let localStorageServiceSpy: jasmine.SpyObj<LocalStorageService>;
let windowServiceSpy: jasmine.SpyObj<Window>;
describe('SamplesComponent', () => {
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 {LocalStorageService} from 'angular-2-local-storage';
// TODO: turn off sort field
interface LoadSamplesOptions {
toPage?: number;

View File

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

View File

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

View File

@ -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<ApiService>;
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<ApiService>;
});
it('should be created', () => {

View File

@ -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<ApiService>;
let localStorageServiceSpy: jasmine.SpyObj<LocalStorageService>;

View File

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

View File

@ -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<Router>;
let apiServiceSpy: jasmine.SpyObj<ApiService>;
let loginServiceSpy: jasmine.SpyObj<LoginService>;
describe('SettingsComponent', () => {
let component: SettingsComponent;
let fixture: ComponentFixture<SettingsComponent>;
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<Router>;
apiServiceSpy = TestBed.inject(ApiService) as jasmine.SpyObj<ApiService>;
loginServiceSpy = TestBed.inject(LoginService) as jasmine.SpyObj<LoginService>;
}));
beforeEach(() => {
fixture = TestBed.createComponent(SettingsComponent);
component = fixture.componentInstance;
component.ngOnInit();
fixture.detectChanges();
});

View File

@ -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<ApiService>;
let validationServiceSpy: jasmine.SpyObj<ValidationService>;
let dataServiceSpy: jasmine.SpyObj<DataService>;
describe('TemplatesComponent', () => {
let component: TemplatesComponent;
let fixture: ComponentFixture<TemplatesComponent>;
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<ApiService>;
validationServiceSpy = TestBed.inject(ValidationService) as jasmine.SpyObj<ValidationService>;
dataServiceSpy = TestBed.inject(DataService) as jasmine.SpyObj<DataService>;
}));
beforeEach(() => {
fixture = TestBed.createComponent(TemplatesComponent);
component = fixture.componentInstance;
component.ngOnInit();
fixture.detectChanges();
});

View File

@ -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<ApiService>;
let modalServiceSpy: jasmine.SpyObj<ModalService>;
let loginServiceSpy: jasmine.SpyObj<LoginService>;
describe('UsersComponent', () => {
let component: UsersComponent;
let fixture: ComponentFixture<UsersComponent>;
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<ApiService>;
modalServiceSpy = TestBed.inject(ModalService) as jasmine.SpyObj<ModalService>;
loginServiceSpy = TestBed.inject(LoginService) as jasmine.SpyObj<LoginService>;
}));
beforeEach(() => {
fixture = TestBed.createComponent(UsersComponent);
component = fixture.componentInstance;
component.ngOnInit();
fixture.detectChanges();
});

View File

@ -1,8 +1,14 @@
// 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', () => {
// it('should create an instance', () => {
// const directive = new ValidateDirective();
// const directive = new ValidateDirective(validationServiceSpy);
// expect(directive).toBeTruthy();
// });
// });