definma-ui/src/app/samples/samples.component.spec.ts

73 lines
3.0 KiB
TypeScript
Raw Normal View History

2020-08-16 20:01:56 +02:00
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();
});
});