@@ -4,29 +4,14 @@ import { BookDataService } from '../shared/book-data.service';
44import { ComponentFixture , TestBed , inject } from '@angular/core/testing' ;
55
66import { BookDetailComponent } from './book-detail.component' ;
7- import { DebugElement , Component , NO_ERRORS_SCHEMA } from '@angular/core' ;
7+ import { DebugElement , Component } from '@angular/core' ;
88import { ActivatedRoute , Router } from '@angular/router' ;
99import { Location } from "@angular/common" ;
1010import { Observable } from 'rxjs' ;
1111
12- export class MockActivatedRoute {
13- parent : any ;
14- params : any ;
15- snapshot = { } ;
16-
17- constructor ( options ) {
18- this . parent = options . parent ;
19- this . params = options . params ;
20- }
21- }
22-
23-
2412describe ( 'BookDetailComponent' , ( ) => {
2513 let component : BookDetailComponent ;
2614 let fixture : ComponentFixture < BookDetailComponent > ;
27- let router : Router ;
28- let location : Location ;
29- let serviceSpy : jasmine . Spy ;
3015
3116 beforeEach ( ( ) => {
3217 TestBed . configureTestingModule ( {
@@ -36,33 +21,23 @@ describe('BookDetailComponent', () => {
3621 imports : [
3722 RouterTestingModule
3823 ] ,
39- providers : [
40- { provide : BookDataService , useClass : BookStaticAsyncDataService } ,
41- {
42- provide : ActivatedRoute ,
43- useValue : new MockActivatedRoute ( {
44- params : Observable . of ( { isbn : '978-0-20163-361-0' } ) ,
45- parent : new MockActivatedRoute ( { } )
46- } )
47- }
48- ]
24+ providers : [ ]
4925 } )
5026 . compileComponents ( ) ;
5127 } ) ;
5228
5329 beforeEach ( inject ( [ BookDataService ] , ( service : BookDataService ) => {
5430 fixture = TestBed . createComponent ( BookDetailComponent ) ;
5531 component = fixture . componentInstance ;
56- serviceSpy = spyOn ( service , 'getBookByIsbn' ) . and . callThrough ( ) ;
5732 fixture . detectChanges ( ) ;
5833 } ) ) ;
5934
60- it ( 'should read a book via BookData service' , ( ) => {
61- expect ( serviceSpy . calls . argsFor ( 0 ) ) . toEqual ( [ '978-0-20163-361-0' ] ) ;
35+ it ( 'should call the BookData service with the correct ISBN ' , ( ) => {
36+ expect ( true ) . toBeFalsy ( ) ;
6237 } ) ;
6338
64- it ( 'should load the book to the component' , ( ) => {
65- expect ( component . book . isbn ) . toBe ( '978-0-20163-361-0' ) ;
39+ it ( 'should load the book to the component to component.book ' , ( ) => {
40+ expect ( true ) . toBeFalsy ( ) ;
6641 } ) ;
6742
6843} ) ;
0 commit comments