Skip to content

Commit 75ad142

Browse files
committed
Write tests. Fixes angular#13951
1 parent 569f8a6 commit 75ad142

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/ng/controllerSpec.js

+21
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,27 @@ describe('$controller', function() {
5757
expect(ctrl instanceof BarCtrl).toBe(true);
5858
});
5959

60+
it('should return true when having an existing controller', function() {
61+
var FooCtrl = function($scope) { $scope.foo = 'foo'; },
62+
scope = {},
63+
ctrl;
64+
65+
$controllerProvider.register({FooCtrl: FooCtrl});
66+
67+
ctrl = $controller('FooCtrl', {$scope: scope});
68+
expect(ctrl.has('FooCtrl')).toBe(true);
69+
});
70+
71+
it('should return false when not having a non existing controller', function() {
72+
var FooCtrl = function($scope) { $scope.foo = 'foo'; },
73+
scope = {},
74+
ctrl;
75+
76+
$controllerProvider.register({FooCtrl: FooCtrl});
77+
78+
ctrl = $controller('FooCtrl', {$scope: scope});
79+
expect(ctrl.has('whatever')).toBe(false);
80+
});
6081

6182
it('should allow registration of controllers annotated with arrays', function() {
6283
var FooCtrl = function($scope) { $scope.foo = 'bar'; },

0 commit comments

Comments
 (0)