File tree Expand file tree Collapse file tree
tour-of-heroes/src/app/hero.component Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { By } from '@angular/platform-browser';
44import { HeroComponent } from './hero.component' ;
55import { Hero } from '../shared/hero' ;
66
7- @Component ( { selector : 'app-test' , template : `<app-hero [hero]="hero" (delete)="onDelete ($event)"></app-hero>` } )
7+ @Component ( { selector : 'app-test' , template : `<app-hero [hero]="hero" (delete)="onDeleteClick ($event)"></app-hero>` } )
88class TestContainerComponent {
99 hero : Hero ;
1010 onDeleteClick = jasmine . createSpy ( 'onDelete' ) ;
@@ -32,13 +32,13 @@ describe('HeroComponent', () => {
3232 fixture . detectChanges ( ) ;
3333
3434 const button = fixture . debugElement . query ( By . css ( 'button' ) ) ;
35- button . triggerEventHandler ( 'click' , { stopPropagation : jasmine . createSpy ( 'stopPropagation' ) } ) ;
35+ const stopPropagationSpy = jasmine . createSpy ( 'stopPropagation' ) ;
36+ button . triggerEventHandler ( 'click' , { stopPropagation : stopPropagationSpy } ) ;
3637 fixture . detectChanges ( ) ;
3738
3839 const deleteClickSpy = fixture . componentInstance . onDeleteClick ;
3940 expect ( deleteClickSpy ) . toHaveBeenCalled ( ) ;
4041
41- const clickEvent = deleteClickSpy . mostRecentCall . args [ 0 ] ;
42- expect ( clickEvent . stopPropagation ) . toHaveBeenCalled ( ) ;
42+ expect ( stopPropagationSpy ) . toHaveBeenCalled ( ) ;
4343 } ) ;
4444} ) ;
You can’t perform that action at this time.
0 commit comments