I am learning Angular unit testing from some online courses.
Here is a part of the code.
it("should find a course by id", () => {
coursesService.findCourseById(12).subscribe((course) => {
expect(course).toBeTruthy();
expect(course.id).toBe(12);
});
const req = httpTestingController.expectOne("/api/courses/12");
expect(req.request.method).toEqual("GET");
req.flush(COURSES[12]);
httpTestingController.verify();
});
The definition of verify() on the angular document is:
Verify that no unmatched requests are outstanding.
I was wondering why I need to call verify() when I already called expectOne().