For some reason these two specs are passing, however the second spec is testing interpolation within the template, with async data from a service. Why is it not necessary to wrap the callback function with async?
describe('SaangComponent', () => {
let component: SaangComponent;
let fixture: ComponentFixture<SaangComponent>;
let compiled: HTMLElement;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ SaangComponent ],
providers: [
{provide: GetSomeService, useValue: getSomeServiceMock}
]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(SaangComponent);
component = fixture.componentInstance;
compiled = fixture.debugElement.query(By.css('h1')).nativeElement;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should update the h1 attribute with the title', () => {
fixture.detectChanges();
const expectedText = compiled.innerHTML;
expect(expectedText).toEqual('lord');
});
});
const getSomeServiceMock = {
getSomeData() {
return Observable.of({title: 'lord'});
}
};