The app is working properly with my module. But building the following mock returns :
$global_vars is not defined
I imagine that I'm not injecting the module properly. What am I missing here?
describe('CalendarController', function() {
beforeEach(module("$global_vars"));
beforeEach(inject(function($rootScope, $controller, $location, $injector, $global_vars) {
var $httpBackend;
$httpBackend = $injector.get('$httpBackend');
return this.controller = $controller(CalendarController, {
$scope: this.scope,
$location: $location,
$global_vars: $global_vars
});
}));
return it("can be instantiated", function() {
return expect($global_vars).not.toBeNull();
});
});
note: this is a coffeescript translation to vanilla js
UPDATE
Ok so by doing this I get another, possibly better error?
Error: Unknown provider: $httpProvider <- $http <- $global_vars
.
describe 'CalendarController', ->
beforeEach module("$global_vars")
beforeEach module("GlobalService")
beforeEach inject ($rootScope, $controller, $location, $injector) ->
$injector = angular.injector [ '$global_vars' ]
$global_vars = $injector.get('$global_vars')
$global_vars = $injector.get('$global_vars')
@controller = $controller CalendarController, {$scope: @scope, $location: $location}
The bare bones of my backbone.js
angular.module("VarsService", []).factory "$global_vars", ["$http", '$location', ($http, $location) ->
global_vars.get_calendar = ->
console.log 'blam!'