@@ -27,6 +27,11 @@ describe("HomeComponent", () => {
27
27
let fixture : ComponentFixture < HomeComponent > ;
28
28
let component : HomeComponent ;
29
29
let el : DebugElement ;
30
+ let coursesService : any ;
31
+
32
+ const beginnerCourses = setupCourses ( ) . filter (
33
+ ( course ) => course . category == "BEGINNER"
34
+ ) ;
30
35
31
36
// using to compile our component
32
37
beforeEach (
@@ -49,6 +54,7 @@ describe("HomeComponent", () => {
49
54
fixture = TestBed . createComponent ( HomeComponent ) ;
50
55
component = fixture . componentInstance ;
51
56
el = fixture . debugElement ;
57
+ coursesService = TestBed . inject ( CoursesService ) ;
52
58
} ) ;
53
59
} )
54
60
) ;
@@ -58,7 +64,18 @@ describe("HomeComponent", () => {
58
64
} ) ;
59
65
60
66
it ( "should display only beginner courses" , ( ) => {
61
- pending ( ) ;
67
+ // pending();
68
+ // coursesService.findAllCourses.and.returnValue(
69
+ // setupCourses().filter((course) => course.category == "BEGINNER")
70
+ // );
71
+ // need to return observable
72
+ coursesService . findAllCourses . and . returnValue ( of ( beginnerCourses ) ) ;
73
+
74
+ fixture . detectChanges ( ) ;
75
+
76
+ const tabs = el . queryAll ( By . css ( ".mat-tab-label" ) ) ;
77
+
78
+ expect ( tabs . length ) . toBe ( 1 , "Unexpected number of tabs found" ) ;
62
79
} ) ;
63
80
64
81
it ( "should display only advanced courses" , ( ) => {
0 commit comments