Thursday, 12 September 2013

AngularJS - How to write unit test case for ng-init directive?

AngularJS - How to write unit test case for ng-init directive?

I have ng-init set to call a function init in my controller scope.
<div ng-init="init('start')" ng-controller="ProgressController"></div>
My test suite is as below.
describe("Progress controller", function () {
var $scope = null;
var controller = null;
beforeEach(module('MyApp'));
beforeEach(inject(function ($rootScope, $controller) {
$scope = $rootScope.$new();
controller = $controller('ProgressController', {
$scope: $scope
});
}));
}
How do I include ng-init in my test case so that whenever the controller
is initialized, init function should be triggered?

No comments:

Post a Comment