Created
August 14, 2012 02:13
-
-
Save alexeygolev/3345781 to your computer and use it in GitHub Desktop.
angular.js jasmine test spec for controller defined inside a module in coffeescript
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', -> | |
describe 'PhoneListCtrl', -> | |
beforeEach module 'phonesCat.controllers' | |
ctrl = undefined | |
scope = undefined | |
beforeEach inject ($controller, $rootScope) -> | |
scope = $rootScope.$new(); | |
ctrl = $controller 'PhoneListCtrl', { | |
$scope: scope | |
} | |
it 'should create "phones" model with 3 phones', -> | |
expect(scope.phones.length).toBe 3 |
For inject function, see this https://docs.angularjs.org/api/ngMock/function/angular.mock.inject
It says that "This function is also published on window for easy access."
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where are the module and inject functions defined? I'm getting an error when running the test with karma...