diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/service/controllerSpec.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/service/controllerSpec.js b/test/service/controllerSpec.js new file mode 100644 index 00000000..8b12eceb --- /dev/null +++ b/test/service/controllerSpec.js @@ -0,0 +1,38 @@ +'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); + }); +}); |
