@@ -4,105 +4,57 @@ import {
4
4
async ,
5
5
ComponentFixture ,
6
6
} from '@angular/core/testing' ;
7
+ import { APP_BASE_HREF } from '@angular/common' ;
7
8
import { RouterTestingModule } from '@angular/router/testing' ;
8
- import { XHRBackend , Response , ResponseOptions } from '@angular/http' ;
9
- import { MockBackend } from '@angular/http/testing' ;
10
- import { CovalentCoreModule , TdLoadingService } from '@covalent/core' ;
11
- import { CovalentHttpModule } from '@covalent/http' ;
9
+ import { CovalentCoreModule , TdMediaService } from '@covalent/core' ;
12
10
import { DashboardProductComponent } from './dashboard-product.component' ;
13
- import { ChartComponent } from '../../components/chart/chart.component' ;
14
11
15
12
describe ( 'Component: DashboardProduct' , ( ) => {
16
13
17
14
let noop : ( ) => void = ( ) => {
18
15
// noop method
19
16
} ;
20
17
21
- let generalResponses : Map < string , Response > = new Map < string , Response > ( ) ;
22
- generalResponses . set ( 'assets/icons/covalent.svg' , new Response ( new ResponseOptions ( {
23
- status : 200 , body : '<svg></svg>' ,
24
- } ) ) ) ;
25
- generalResponses . set ( 'assets/icons/github.svg' , new Response ( new ResponseOptions ( {
26
- status : 200 , body : '<svg></svg>' ,
27
- } ) ) ) ;
28
-
29
18
beforeEach ( async ( ( ) => {
30
19
TestBed . configureTestingModule ( {
31
20
imports : [
32
21
CovalentCoreModule . forRoot ( ) ,
33
- CovalentHttpModule . forRoot ( ) ,
34
22
RouterTestingModule ,
35
23
] ,
36
24
declarations : [
37
25
DashboardProductComponent ,
38
- ChartComponent ,
39
26
] ,
40
27
providers : [
41
- MockBackend ,
42
- { provide : XHRBackend , useExisting : MockBackend } ,
43
- { provide : TdLoadingService , useValue : {
28
+ { provide : APP_BASE_HREF , useValue : '/' } ,
29
+ { provide : TdMediaService , useValue : {
30
+ registerQuery : noop ,
31
+ query : noop ,
32
+ broadcast : noop ,
33
+ createComponent : noop ,
44
34
createReplaceComponent : noop ,
45
35
createOverlayComponent : noop ,
46
36
register : noop ,
47
37
resolve : noop ,
48
38
} ,
49
39
} ,
50
40
] ,
51
- } ) ;
52
- TestBed . compileComponents ( ) ;
41
+ } )
42
+ . compileComponents ( ) ;
53
43
} ) ) ;
54
44
55
- it ( 'should create the component' , async ( inject ( [ MockBackend ] , ( mockBackend : MockBackend ) => {
56
- let responses : Map < string , Response > = new Map < string , Response > ( generalResponses ) ;
57
- mockBackend . connections . subscribe ( ( connection : any ) => {
58
- connection . mockRespond ( responses . get ( connection . request . url ) ) ;
59
- } ) ;
60
- responses . set ( 'data/items.json' , new Response ( new ResponseOptions ( {
61
- status : 200 , body : JSON . stringify ( [ {
62
- item_id : 1 ,
63
- name : 'Suzy Cuningham' ,
64
- description : 'updated her account' ,
65
- icon : 'account_circle' ,
66
- created : '07/13/2016 11:05 AM' ,
67
- } , {
68
- item_id : 2 ,
69
- name : 'Bobby Daniels' ,
70
- description : 'made a deposit of $25.15' ,
71
- icon : 'account_balance_wallet' ,
72
- created : '07/01/2016 03:41 PM' ,
73
- } ] ) ,
74
- } ) ) ) ;
75
- responses . set ( 'data/users.json' , new Response ( new ResponseOptions ( {
76
- status : 200 , body : JSON . stringify ( [ {
77
- displayName : 'Suzy Cuningham' ,
78
- id : 'suzy.cuningham' ,
79
-
80
- created : '10/01/2015 11:05 AM' ,
81
- lastAccess : '12/23/2015 11:05 AM' ,
82
- siteAdmin : true ,
83
- } , {
84
- displayName : 'Bobby Daniels' ,
85
- id : 'bobbyD' ,
86
-
87
- created : '10/01/2015 11:05 AM' ,
88
- lastAccess : '12/23/2015 11:05 AM' ,
89
- siteAdmin : false ,
90
- } ] ) ,
91
- } ) ) ) ;
92
-
45
+ it ( 'should create the component' , ( done : any ) => {
93
46
let fixture : ComponentFixture < any > = TestBed . createComponent ( DashboardProductComponent ) ;
94
47
let testComponent : DashboardProductComponent = fixture . debugElement . componentInstance ;
95
48
let element : HTMLElement = fixture . nativeElement ;
96
49
97
- expect ( element . querySelector ( '.item-list' ) ) . toBeTruthy ( ) ;
98
- expect ( element . querySelector ( '.user-list' ) ) . toBeTruthy ( ) ;
99
50
testComponent . ngAfterViewInit ( ) ;
100
51
fixture . detectChanges ( ) ;
52
+ expect ( element . querySelector ( 'td-layout-manage-list' ) ) . toBeTruthy ( ) ;
101
53
fixture . whenStable ( ) . then ( ( ) => {
102
- expect ( element . querySelectorAll ( '.item-list a[md-list-item ]') . length )
103
- . toBe ( testComponent . items . length ) ;
104
- expect ( element . querySelectorAll ( '.user-list md-list-item' ) . length )
105
- . toBe ( testComponent . users . length ) ;
54
+ expect ( element . querySelector ( 'a[ng-reflect-router-link="/product" ]') ) . toBeTruthy ( ) ;
55
+ expect ( element . querySelector ( 'a[ng-reflect-router-link="stats"]' ) ) . toBeTruthy ( ) ;
56
+ expect ( element . querySelector ( 'a[ng-reflect-router-link="features"]' ) ) . toBeTruthy ( ) ;
57
+ done ( ) ;
106
58
} ) ;
107
- } ) ) ) ;
59
+ } ) ;
108
60
} ) ;
0 commit comments