@@ -873,7 +873,9 @@ describe('treeControl', function() {
873873 element . find ( 'li:eq(1) .tree-branch-head' ) . click ( ) ;
874874 expect ( $rootScope . expandedNodes ) . not . toContain ( $rootScope . treedata [ 1 ] ) ;
875875 } ) ;
876+ } ) ;
876877
878+ describe ( 'expanded-nodes binding' , function ( ) {
877879 it ( 'should retain expansions after full model refresh' , function ( ) {
878880 var testTree = createSubTree ( 2 , 2 ) ;
879881 $rootScope . treedata = angular . copy ( testTree ) ;
@@ -888,6 +890,32 @@ describe('treeControl', function() {
888890 expect ( element . find ( 'li:eq(0)' ) . hasClass ( 'tree-expanded' ) ) . toBeTruthy ( ) ;
889891 } ) ;
890892
893+ it ( 'should support a large tree' , function ( ) {
894+ var testTree = createSubTree ( 3 , 10 ) ;
895+ element = $compile ( '<treecontrol tree-model="treedata" expanded-nodes="expandedNodes">{{node.label}}</treecontrol>' ) ( $rootScope ) ;
896+
897+ var expandedNodes = [ ] ;
898+ function diveInto ( parent ) {
899+ expandedNodes . push ( parent ) ;
900+ if ( Array . isArray ( parent . children ) ) {
901+ parent . children . forEach ( function ( child ) {
902+ diveInto ( child ) ;
903+ } ) ;
904+ }
905+ }
906+ testTree . forEach ( function ( rootNode ) {
907+ diveInto ( rootNode ) ;
908+ } ) ;
909+
910+ $rootScope . treedata = testTree ;
911+ $rootScope . $digest ( ) ;
912+ $rootScope . expandedNodes = expandedNodes ;
913+ $rootScope . $digest ( ) ;
914+
915+ //console.log(element);
916+ expect ( element . find ( 'li.tree-expanded' ) . length + element . find ( 'li.tree-leaf' ) . length ) . toBe ( $rootScope . expandedNodes . length ) ;
917+ } ) ;
918+
891919 } ) ;
892920
893921 describe ( 'external template' , function ( ) {
0 commit comments