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

69 lines
2.3 KiB
TypeScript
Raw Normal View History

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