I'm facing some weird issue with a test suite I set up.
Template :
<a href="#" (click)="blop($event)"></a>
HomeComponent :
export class HomeComponent {
public test: boolean;
public constructor () {
this.test = false;
}
public blop($event) {
this.test = true;
}
}
The test :
describe('Home Component : ', () => {
var builder;
var app;
beforeEach(inject([HomeComponent, TestComponentBuilder], (app, tcb) => {
builder = tcb;
app = app;
}));
it('should return test = true after click...', async(() => {
builder.createAsync(HomeComponent).then((fixture: ComponentFixture<HomeComponent>) => {
spyOn(fixture.componentInstance, 'blop');
fixture.detectChanges();
var compiled = fixture.debugElement.nativeElement;
compiled.querySelector('a').click();
expect(fixture.componentInstance.test).toBe(true);
expect(fixture.componentInstance.blop).toHaveBeenCalled();
});
}));
});
I get an error output on : Expected false to be true.
BUT, if I comment the spy and the last expect, it works.
Do you have any idea about what I am doing wrong ?
Thanks
M