|
@ -1,11 +1,30 @@ |
|
|
import { TestBed, async } from '@angular/core/testing'; |
|
|
import { TestBed, async } from '@angular/core/testing'; |
|
|
import { AppComponent } from './app.component'; |
|
|
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', () => { |
|
|
describe('AppComponent', () => { |
|
|
|
|
|
|
|
|
|
|
|
const languageServiceSpy: jasmine.SpyObj<LanguageService> = jasmine.createSpyObj('LanguageService', ['getLang']); |
|
|
|
|
|
|
|
|
beforeEach(async(() => { |
|
|
beforeEach(async(() => { |
|
|
TestBed.configureTestingModule({ |
|
|
TestBed.configureTestingModule({ |
|
|
declarations: [ |
|
|
declarations: [ |
|
|
AppComponent |
|
|
AppComponent |
|
|
], |
|
|
], |
|
|
|
|
|
imports: [ |
|
|
|
|
|
TranslateModule.forRoot(), |
|
|
|
|
|
RouterTestingModule |
|
|
|
|
|
], |
|
|
|
|
|
providers: [ |
|
|
|
|
|
{ provide: LanguageService, useValue: languageServiceSpy }, |
|
|
|
|
|
], |
|
|
|
|
|
schemas: [NO_ERRORS_SCHEMA] |
|
|
}).compileComponents(); |
|
|
}).compileComponents(); |
|
|
})); |
|
|
})); |
|
|
it('should create the app', async(() => { |
|
|
it('should create the app', async(() => { |
|
@ -13,15 +32,4 @@ describe('AppComponent', () => { |
|
|
const app = fixture.debugElement.componentInstance; |
|
|
const app = fixture.debugElement.componentInstance; |
|
|
expect(app).toBeTruthy(); |
|
|
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!'); |
|
|
|
|
|
})); |
|
|
|
|
|
}); |
|
|
}); |
|
|