@@ -873,7 +873,9 @@ describe('treeControl', function() {
873
873
element . find ( 'li:eq(1) .tree-branch-head' ) . click ( ) ;
874
874
expect ( $rootScope . expandedNodes ) . not . toContain ( $rootScope . treedata [ 1 ] ) ;
875
875
} ) ;
876
+ } ) ;
876
877
878
+ describe ( 'expanded-nodes binding' , function ( ) {
877
879
it ( 'should retain expansions after full model refresh' , function ( ) {
878
880
var testTree = createSubTree ( 2 , 2 ) ;
879
881
$rootScope . treedata = angular . copy ( testTree ) ;
@@ -888,6 +890,32 @@ describe('treeControl', function() {
888
890
expect ( element . find ( 'li:eq(0)' ) . hasClass ( 'tree-expanded' ) ) . toBeTruthy ( ) ;
889
891
} ) ;
890
892
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
+
891
919
} ) ;
892
920
893
921
describe ( 'external template' , function ( ) {
0 commit comments