Skip to content

Commit a8a4c76

Browse files
committed
Update courses.service.spec.ts
1 parent c5fa13c commit a8a4c76

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
HttpTestingController,
44
} from "@angular/common/http/testing";
55
import { TestBed } from "@angular/core/testing";
6-
import { COURSES, findCourseById } from '../../../../server/db-data';
6+
import { COURSES, findCourseById } from "../../../../server/db-data";
77
import { CoursesService } from "./courses.service";
88
describe("CoursesService", () => {
99
let coursesService: CoursesService,
@@ -35,11 +35,16 @@ describe("CoursesService", () => {
3535
req.flush({ payload: Object.values(COURSES) });
3636
});
3737

38-
it("should find a course by id", () => {
39-
coursesService.findCourseById(12).subscribe((course) => {
40-
expect(course).toBeTruthy("No courses returned");
41-
expect(course.id).toBe(12, "incorrect course id");
42-
43-
38+
it("should find a course by id", () => {
39+
coursesService.findCourseById(12).subscribe((course) => {
40+
expect(course).toBeTruthy("No courses returned");
41+
expect(course.id).toBe(12, "incorrect course id");
4442
});
43+
44+
const req = httpTestingController.expectOne("/api/courses/12");
45+
46+
expect(req.request.method).toEqual("GET");
47+
48+
req.flush(COURSES[12]);
49+
});
4550
});

0 commit comments

Comments
 (0)