@@ -233,7 +233,7 @@ it upwards to the heroList component, which updates the original data.
233
233
</file>
234
234
235
235
<file name="heroDetail.js">
236
- function HeroDetailController($scope, $element, $attrs ) {
236
+ function HeroDetailController() {
237
237
var ctrl = this;
238
238
239
239
ctrl.update = function(prop, value) {
@@ -455,42 +455,32 @@ The examples use the [Jasmine](http://jasmine.github.io/) testing framework.
455
455
describe('component: heroDetail', function() {
456
456
var component, scope, hero, $componentController;
457
457
458
- beforeEach(module('simpleComponent '));
458
+ beforeEach(module('heroApp '));
459
459
460
460
beforeEach(inject(function($rootScope, _$componentController_) {
461
461
scope = $rootScope.$new();
462
462
$componentController = _$componentController_;
463
463
hero = {name: 'Wolverine'};
464
464
}));
465
465
466
- it('should set the default values of the hero', function() {
467
- // It's necessary to always pass the scope in the locals, so that the controller instance can be bound to it
468
- component = $componentController('heroDetail', {$scope: scope});
469
-
470
- expect(component.hero).toEqual({
471
- name: undefined,
472
- location: 'unknown'
473
- });
474
- });
475
-
476
466
it('should assign the name bindings to the hero object', function() {
477
467
// Here we are passing actual bindings to the component
478
-
479
468
component = $componentController('heroDetail',
480
- {$scope: scope} ,
469
+ null ,
481
470
{hero: hero}
482
471
);
483
472
expect(component.hero.name).toBe('Wolverine');
484
473
});
485
474
486
475
it('should call the onDelete binding when a hero is deleted', function() {
476
+ var deleteSpy = jasmine.createSpy('deleteSpy');
487
477
component = $componentController('heroDetail',
488
- {$scope: scope} ,
489
- {hero: hero, onDelete: jasmine.createSpy(' deleteSpy') }
478
+ null ,
479
+ {hero: hero, onDelete: deleteSpy}
490
480
);
491
481
492
482
component.onDelete({hero: component.hero});
493
- expect(spy(' deleteSpy')) .toHaveBeenCalledWith(component.hero);
483
+ expect(deleteSpy) .toHaveBeenCalledWith({hero: component.hero} );
494
484
});
495
485
496
486
});
0 commit comments