I am using Angluar2 and a WebAPI to develop a website. I am having an issue with jasmine where I need to test if the API has properly returned a data object.
My component calls on a service which then uses a angular2 HTTP.get to get the proper data object. Using the Karma debugger I found out that my component is updating and receiving information but only after a test finishes.
beforeEach(() => {
fixture = TestBed.createComponent(ReviewComponent);
component = fixture.componentInstance;
component.reviewId = 1; //sets id to proper value
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should get a desk review', () => {
spyOn(component, "getkReview");
component.getReview();
expect(component.getReview).toHaveBeenCalled();
});
How can I get my data object to update so I can compare the returned data to expected data within my test?
Aucun commentaire:
Enregistrer un commentaire