angular.js/test/service/controllerSpec.js
Vojta Jina dbffbefb7c refactor($controller): Add $controller service for instantiating controllers
So that we can allow user to override this service and use BC hack:
https://gist.github.com/1649788
2012-01-23 13:11:12 -08:00

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);
});
});