Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit b9d76bf

Browse files
mjwwitgkalpak
authored andcommitted
docs(guide/component): several unit-test fixes and remove obsolete testcase
Fixes #14426 Closes #14443
1 parent 2310e10 commit b9d76bf

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

docs/content/guide/component.ngdoc

+7-17
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ it upwards to the heroList component, which updates the original data.
233233
</file>
234234

235235
<file name="heroDetail.js">
236-
function HeroDetailController($scope, $element, $attrs) {
236+
function HeroDetailController() {
237237
var ctrl = this;
238238

239239
ctrl.update = function(prop, value) {
@@ -455,42 +455,32 @@ The examples use the [Jasmine](http://jasmine.github.io/) testing framework.
455455
describe('component: heroDetail', function() {
456456
var component, scope, hero, $componentController;
457457

458-
beforeEach(module('simpleComponent'));
458+
beforeEach(module('heroApp'));
459459

460460
beforeEach(inject(function($rootScope, _$componentController_) {
461461
scope = $rootScope.$new();
462462
$componentController = _$componentController_;
463463
hero = {name: 'Wolverine'};
464464
}));
465465

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-
476466
it('should assign the name bindings to the hero object', function() {
477467
// Here we are passing actual bindings to the component
478-
479468
component = $componentController('heroDetail',
480-
{$scope: scope},
469+
null,
481470
{hero: hero}
482471
);
483472
expect(component.hero.name).toBe('Wolverine');
484473
});
485474

486475
it('should call the onDelete binding when a hero is deleted', function() {
476+
var deleteSpy = jasmine.createSpy('deleteSpy');
487477
component = $componentController('heroDetail',
488-
{$scope: scope},
489-
{hero: hero, onDelete: jasmine.createSpy('deleteSpy')}
478+
null,
479+
{hero: hero, onDelete: deleteSpy}
490480
);
491481

492482
component.onDelete({hero: component.hero});
493-
expect(spy('deleteSpy')).toHaveBeenCalledWith(component.hero);
483+
expect(deleteSpy).toHaveBeenCalledWith({hero: component.hero});
494484
});
495485

496486
});

0 commit comments

Comments
 (0)