Skip to content

Commit 19bf43d

Browse files
heroes: more refactoring of HeroComponent spec
1 parent 47f51e0 commit 19bf43d

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

tour-of-heroes/src/app/hero.component/hero.component.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { By } from '@angular/platform-browser';
44
import { HeroComponent } from './hero.component';
55
import { 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>`})
88
class 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
});

0 commit comments

Comments
 (0)