Skip to content

Commit 3b7b6d6

Browse files
author
Your Name
committed
Angular Testing Course
1 parent 89f287a commit 3b7b6d6

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/app/courses/services/courses.services.spec.ts

+22
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,31 @@ describe('CoursesService', () => {
4747

4848
req.flush({payload: Object.values(COURSES)});
4949

50+
});
51+
52+
53+
it('should find a course by id', () => {
54+
55+
coursesService.findCourseById(12)
56+
.subscribe(course => {
57+
58+
expect(course).toBeTruthy();
59+
expect(course.id).toBe(12);
60+
61+
});
62+
63+
const req = httpTestingController.expectOne('/api/courses/12');
64+
65+
expect(req.request.method).toEqual("GET");
66+
67+
req.flush(COURSES[12]);
5068

5169
});
5270

71+
afterEach(() => {
72+
73+
httpTestingController.verify();
74+
});
5375

5476
});
5577

0 commit comments

Comments
 (0)