I've written a short unit test based on the example from the Angular unit-testing documentation. I've tried to create a jsfiddle with no luck, so please bear with me.
# app definition
app = module 'myApp', []
.controller 'myCtrl', ['$scope', ($scope) ->$scope.foo = 'foo']
# test
describe 'myCtrl tests', () ->
beforeEach module 'myApp'
$controller = undefined
beforeEach inject (_$controller_) ->
$controller = _$controller_
describe 'TestEditCtrl', () ->
it 'should not throw an error', () ->
$scope = {}
controller = $controller 'myCtrl',{$scope: $scope}
expect ($scope.foo).toEqual 'foo'
When I run this test, I get "TypeError: undefined is not a function" for $scope.foo and the test fails.
Aucun commentaire:
Enregistrer un commentaire