Created
August 14, 2012 01:47
-
-
Save alexeygolev/3345655 to your computer and use it in GitHub Desktop.
angular.js jasmine test spec for controller defined inside a module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
/* jasmine specs for controllers go here */ | |
describe('PhoneCat controllers', function() { | |
describe('PhoneListCtrl', function() { | |
beforeEach(module('phonesCat.controllers')); | |
var ctrl, scope; | |
beforeEach(inject(function($controller, $rootScope) { | |
scope = $rootScope.$new(); | |
ctrl = $controller('PhoneListCtrl', { | |
$scope: scope | |
}); | |
})); | |
it('should create "phones" model with 3 phones', function() { | |
expect(scope.phones.length).toBe(3); | |
}); | |
}); | |
}); |
In this case it's a controller. In angularjs anything is treated as a module: a controller is a module, just like a service and a directive.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Question...
What type of 'module' is being referred to here?
I'm just starting to get into testing and the work 'modules' get's thrown around a lot.