I'm testing a controller containing
$document.on('click', $scope.$apply.bind($scope, $scope.deactivate));
When I test this controller using Jasmine & Karma
'use strict';
describe('controllers: ArrayCtrl', function() {
var scope;
beforeEach(module('ironridge'));
beforeEach(inject(function($controller,$rootScope) {
scope = $rootScope.$new();
$controller('ArrayCtrl', {
$scope: scope
});
}));
it('test section ', inject(function($controller) {
expect(scope.pannels.length).toBe(0);
}));
});
I get the following error :
PhantomJS 1.9.8 (Linux 0.0.0) controllers: ArrayCtrl should be located in Quote Section FAILED TypeError: 'undefined' is not a function (evaluating '$scope.$apply.bind($scope, $scope.deactivate)') undefined at /home/hpro/ironridge/src/app/components/array/array.controller.js:183 at invoke (/home/hpro/ironridge/bower_components/angular/angular.js:4219) at instantiate (/home/hpro/ironridge/bower_components/angular/angular.js:4227) at /home/hpro/ironridge/bower_components/angular/angular.js:8533 at /home/hpro/ironridge/bower_components/angular-mocks/angular-mocks.js:1878 at /home/hpro/ironridge/src/app/components/array/array.controller.spec.js:11 at invoke (/home/hpro/ironridge/bower_components/angular/angular.js:4219) at workFn (/home/hpro/ironridge/bower_components/angular-mocks/angular-mocks.js:2437) TypeError: 'undefined' is not an object (evaluating 'scope.pannels.length') undefined at /home/hpro/ironridge/src/app/components/array/array.controller.spec.js:17 at invoke (/home/hpro/ironridge/bower_components/angular/angular.js:4219) at workFn (/home/hpro/ironridge/bower_components/angular-mocks/angular-mocks.js:2437)
help please