Skip to content

Instantly share code, notes, and snippets.

@nfelger
Created October 14, 2013 13:31
Show Gist options
  • Save nfelger/6975667 to your computer and use it in GitHub Desktop.
Save nfelger/6975667 to your computer and use it in GitHub Desktop.
var myModule = angular.module('myModule', []);
myModule.run(function() {
jQuery.ajax({
method: 'GET',
url: '/foo',
dataType: 'json',
async: false,
success: function (data) {
...
}
});
}]);
myModule.controller('myCtrl', ['$scope', function($scope) {
$scope.bar = 'baz';
}]);
'use strict';
describe('myCtrl', function() {
var $scope;
var ctrl;
beforeEach(function() {
module('myModule');
inject(function($rootScope, $controller) {
$scope = $rootScope.$new();
ctrl = $controller('myCtrl', {
$scope: $scope
});
});
});
it('should set bar as baz', function() {
expect($scope.bar).toEqual('baz');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment