File tree 1 file changed +12
-7
lines changed
1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change 3
3
HttpTestingController ,
4
4
} from "@angular/common/http/testing" ;
5
5
import { TestBed } from "@angular/core/testing" ;
6
- import { COURSES , findCourseById } from ' ../../../../server/db-data' ;
6
+ import { COURSES , findCourseById } from " ../../../../server/db-data" ;
7
7
import { CoursesService } from "./courses.service" ;
8
8
describe ( "CoursesService" , ( ) => {
9
9
let coursesService : CoursesService ,
@@ -35,11 +35,16 @@ describe("CoursesService", () => {
35
35
req . flush ( { payload : Object . values ( COURSES ) } ) ;
36
36
} ) ;
37
37
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" ) ;
44
42
} ) ;
43
+
44
+ const req = httpTestingController . expectOne ( "/api/courses/12" ) ;
45
+
46
+ expect ( req . request . method ) . toEqual ( "GET" ) ;
47
+
48
+ req . flush ( COURSES [ 12 ] ) ;
49
+ } ) ;
45
50
} ) ;
You can’t perform that action at this time.
0 commit comments