Skip to content

Instantly share code, notes, and snippets.

@jonnybojangles
Created November 15, 2013 23:19
Show Gist options
  • Save jonnybojangles/7493371 to your computer and use it in GitHub Desktop.
Save jonnybojangles/7493371 to your computer and use it in GitHub Desktop.
Testing controllers that are not declared globally: angular.module().controller();
angular.module('widget.controllers', []).
controller('mainCtrl', ['$scope', function($scope){
$scope.test = 'this is a test';
}]);
/*
* Testing a controller created with angular.module().controller();
* */
describe('Testing controllers created via module\'s controller', function(){
"use strict";
beforeEach(module('widget.controllers'));
describe('mainCtrl', function(){
it('Test hardcoded scope variables are correctly hardcoded.', inject(function($rootScope, $controller){
var scope = $rootScope.$new(),
ctrl = $controller('mainCtrl', { $scope: scope });
expect(scope.test).toBe('this is a test');
}));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment