mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 15:40:22 +00:00
So that we can allow user to override this service and use BC hack: https://gist.github.com/1649788
38 lines
839 B
JavaScript
38 lines
839 B
JavaScript
'use strict';
|
|
|
|
describe('$controller', function() {
|
|
var $controller;
|
|
|
|
beforeEach(inject(function($injector) {
|
|
$controller = $injector.get('$controller');
|
|
}));
|
|
|
|
it('should return instance of given controller class', function() {
|
|
var MyClass = function() {},
|
|
ctrl = $controller(MyClass);
|
|
|
|
expect(ctrl).toBeDefined();
|
|
expect(ctrl instanceof MyClass).toBe(true);
|
|
});
|
|
|
|
it('should inject arguments', inject(function($http) {
|
|
var MyClass = function($http) {
|
|
this.$http = $http;
|
|
};
|
|
|
|
var ctrl = $controller(MyClass);
|
|
expect(ctrl.$http).toBe($http);
|
|
}));
|
|
|
|
|
|
it('should inject given scope', function() {
|
|
var MyClass = function($scope) {
|
|
this.$scope = $scope;
|
|
};
|
|
|
|
var scope = {},
|
|
ctrl = $controller(MyClass, scope);
|
|
|
|
expect(ctrl.$scope).toBe(scope);
|
|
});
|
|
});
|