I am having trouble testing a component with OnPush
change detection strategy.
The test goes like this
it('should show edit button for featured only for owners', () => {
let selector = '.edit-button';
component.isOwner = false;
fixture.detectChanges();
expect(fixture.debugElement.query(By.css(selector))).toBeFalsy();
component.isOwner = true;
fixture.detectChanges();
expect(fixture.debugElement.query(By.css(selector))).toBeTruthy();
});
If I use Default
strategy it works as expected, but with OnPush
the change to isOwner
is not rerendered by the call to detectChanges
. Am I missing something?
Aucun commentaire:
Enregistrer un commentaire