import {TestBed, async, ComponentFixture} from '@angular/core/testing'; import { AppComponent } from './app.component'; 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'; import {Observable} from 'rxjs'; import {Test} from 'tslint'; import {RbCustomInputsModule} from './rb-custom-inputs/rb-custom-inputs.module'; // TODO let loginServiceSpy: jasmine.SpyObj; let routerServiceSpy: Router; let windowServiceSpy: jasmine.SpyObj; describe('AppComponent', () => { let component: AppComponent; let fixture: ComponentFixture; let css; // get native element by css selector beforeEach(async(() => { const loginSpy = jasmine.createSpyObj('LoginService', ['login', 'isLevel', 'isLoggedIn']); const windowSpy = jasmine.createSpyObj('Window', ['location', 'innerWidth', 'innerHeight', 'scroll']); TestBed.configureTestingModule({ declarations: [ AppComponent ], imports: [ RbUiComponentsModule, RbCustomInputsModule, RouterTestingModule ], providers: [ {provide: LoginService, useValue: loginSpy}, {provide: Window, useValue: windowSpy} ] }).compileComponents(); loginServiceSpy = TestBed.inject(LoginService) as jasmine.SpyObj; routerServiceSpy = TestBed.inject(Router); windowServiceSpy = TestBed.inject(Window) as jasmine.SpyObj; })); beforeEach(() => { fixture = TestBed.createComponent(AppComponent); component = fixture.componentInstance; fixture.detectChanges(); css = (selector) => fixture.debugElement.query(By.css(selector)).nativeElement; }); it('should create the app', () => { expect(component).toBeTruthy(); }); it('should have the header', () => { expect(css('rb-full-header')).toBeTruthy(); }); it('should have the correct app title', () => { expect(css('rb-full-header div.sub-brand-content > div').innerText).toBe('BugDEVELOPMENT DeFinMa'); }); it('should have the page container', () => { expect(css('.container')).toBeTruthy(); }); });