如何通过Jasmine单元测试需要父指令控制器的AngularJs指令?

spi*_*tus 5 javascript unit-testing jasmine angularjs

我有AngularJs指令accordionPanel,它require是父指令的控制器accordion.我需要测试accordionPanel指令,以便在调用foldUnfold函数时查看模型是否更改.如何编写单元测试以查看模型是否随foldUnfold通话而变化.这是我的指令的简化版本和我到目前为止的测试是在下面:

   .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) {
                       // some code
                    }
                }
            }
        ])
        .directive("accordionPanel", [

            function() {
                return {
                    templateUrl: "urlblah",
                    transclude: true,
                    replace: true,
                    require: "^accordion",
                    scope: {},
                    link: function(scope, elem, attrs, ctrl, linker) {
                        scope.foldUnfold = function() {
                            // some logic here then
                            scope.changeThisModel=ctrl.isOneOpenOnly();
                        }
                    }
                }
            }
        ])
Run Code Online (Sandbox Code Playgroud)

那是我到目前为止的测试:

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(); // this is fails as scope refers to accordion but I need to access accordionPanel
        expect(scope.changeThisModel).toBe(true);
    });
Run Code Online (Sandbox Code Playgroud)

问题是我无法访问accordionPanel范围foldUnfold.我认为可以通过$$childHead这样的方式访问它,但即使可能,它似乎也不是正确的方法.那我怎么测试呢?