I have an AngularJs accordionPanel directive that require controller of the parent accordion directive. I need to check the accordionPanel directive to see if the model has changed when I call the foldUnfold function. How to write unit test to see if the model changed when calling foldUnfold . Thats a simplified version of my directives and the test I have received so far is below:
.directive("accordion", [ function() { return { templateUrl: "otherurl", transclude: true, replace: true, scope: { }, controller: ["$scope",function($scope) { this.isOneOpenOnly = function() { return $scope.oneOpenOnly; } }], link: function(scope, elem, attrs, ctrl, linker) {
This is my test:
it('Should return unfolded as true', function() { var scope=$rootScope.$new(), element=$compile("<div accordion><div accordion-panel></div></div>")(scope); scope.$digest(); scope.foldUnfold();
The problem is that I cannot access the accordionPanel area where foldUnfold sits. I think it is possible to access it through $$childHead and the like, but even if it is possible, this does not seem to be the right way. How can I check it then?
source share