|
1 |
| -import { DebugElement } from '@angular/core'; |
2 |
| -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
3 |
| -import { By } from '@angular/platform-browser'; |
4 |
| -import { COURSES } from '../../../../server/db-data'; |
5 |
| -import { setupCourses } from '../common/setup-test-data'; |
6 |
| -import { CoursesModule } from '../courses.module'; |
7 |
| -import { sortCoursesBySeqNo } from '../home/sort-course-by-seq'; |
8 |
| -import { Course } from '../model/course'; |
9 |
| -import { CoursesCardListComponent } from './courses-card-list.component'; |
| 1 | +import { DebugElement } from "@angular/core"; |
| 2 | +import { async, ComponentFixture, TestBed } from "@angular/core/testing"; |
| 3 | +import { By } from "@angular/platform-browser"; |
| 4 | +import { COURSES } from "../../../../server/db-data"; |
| 5 | +import { setupCourses } from "../common/setup-test-data"; |
| 6 | +import { CoursesModule } from "../courses.module"; |
| 7 | +import { sortCoursesBySeqNo } from "../home/sort-course-by-seq"; |
| 8 | +import { Course } from "../model/course"; |
| 9 | +import { CoursesCardListComponent } from "./courses-card-list.component"; |
10 | 10 |
|
| 11 | +describe("CoursesCardListComponent", () => { |
| 12 | + // series of variables will be used throughout the test |
11 | 13 |
|
| 14 | + let component: CoursesCardListComponent; |
12 | 15 |
|
13 |
| - |
14 |
| -describe('CoursesCardListComponent', () => { |
15 |
| - |
| 16 | + // test uility type for obtainng/debugging the compoent |
| 17 | + // will bring lots of feature which will be needed to test the component |
| 18 | + let fixture: ComponentFixture<CoursesCardListComponent>; |
16 | 19 |
|
17 | 20 | //init our test
|
18 |
| - beforeEach(() => { |
19 |
| - |
| 21 | + // async is going to wait for this asynchornou operation triggered by the below code and async is going to wait for 5 sec |
| 22 | + beforeEach(async () => { |
20 | 23 | //setting up testing module and provide the dependencies
|
21 | 24 |
|
22 | 25 | TestBed.configureTestingModule({
|
| 26 | + imports: [CoursesModule], |
| 27 | + }) |
| 28 | + .compileComponents() |
| 29 | + .then(() => { |
| 30 | + //setup of our test |
23 | 31 |
|
24 |
| - imports: [CoursesModule] |
| 32 | + fixture = TestBed.createComponent(CoursesCardListComponent); |
25 | 33 |
|
| 34 | + component = fixture.componentInstance; |
| 35 | + }); |
| 36 | + }); |
26 | 37 |
|
27 |
| - }) |
28 |
| - }) |
29 | 38 | it("should create the component", () => {
|
| 39 | + // pending(); |
30 | 40 |
|
31 |
| - pending(); |
| 41 | + expect(component).toBeTruthy(); |
32 | 42 |
|
| 43 | + console.log(component); |
33 | 44 | });
|
34 | 45 |
|
35 |
| - |
36 | 46 | it("should display the course list", () => {
|
37 |
| - |
38 | 47 | pending();
|
39 |
| - |
40 | 48 | });
|
41 | 49 |
|
42 |
| - |
43 | 50 | it("should display the first course", () => {
|
44 |
| - |
45 |
| - pending(); |
46 |
| - |
| 51 | + pending(); |
47 | 52 | });
|
48 |
| - |
49 |
| - |
50 | 53 | });
|
51 |
| - |
52 |
| - |
|
0 commit comments