Skip to content

Commit

Permalink
web-ui: Fix app.component.spec
Browse files Browse the repository at this point in the history
  • Loading branch information
JonSalazar committed Jan 21, 2019
1 parent 8a3669e commit bb23dc1
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions web-ui/src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';

import { TranslateModule } from '@ngx-translate/core';
import { RouterTestingModule } from '@angular/router/testing';

import { DEFAULT_LANG, LanguageService } from './services/language.service';

import { NO_ERRORS_SCHEMA, } from '@angular/core';

describe('AppComponent', () => {

const languageServiceSpy: jasmine.SpyObj<LanguageService> = jasmine.createSpyObj('LanguageService', ['getLang']);

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
imports: [
TranslateModule.forRoot(),
RouterTestingModule
],
providers: [
{ provide: LanguageService, useValue: languageServiceSpy },
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();
}));
it('should create the app', async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
it(`should have as title 'app'`, async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('app');
}));
it('should render title in a h1 tag', async(() => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
}));
});

0 comments on commit bb23dc1

Please sign in to comment.