Skip to content

Commit 80a2a7a

Browse files
committed
Update home.component.spec.ts
1 parent e4f4def commit 80a2a7a

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/app/courses/home/home.component.spec.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ describe("HomeComponent", () => {
2727
let fixture: ComponentFixture<HomeComponent>;
2828
let component: HomeComponent;
2929
let el: DebugElement;
30+
let coursesService: any;
31+
32+
const beginnerCourses = setupCourses().filter(
33+
(course) => course.category == "BEGINNER"
34+
);
3035

3136
// using to compile our component
3237
beforeEach(
@@ -49,6 +54,7 @@ describe("HomeComponent", () => {
4954
fixture = TestBed.createComponent(HomeComponent);
5055
component = fixture.componentInstance;
5156
el = fixture.debugElement;
57+
coursesService = TestBed.inject(CoursesService);
5258
});
5359
})
5460
);
@@ -58,7 +64,18 @@ describe("HomeComponent", () => {
5864
});
5965

6066
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");
6279
});
6380

6481
it("should display only advanced courses", () => {

0 commit comments

Comments
 (0)