@@ -337,13 +337,30 @@ describe('treeControl', function() {
337337 $rootScope . $digest ( ) ;
338338 } ) ;
339339
340- it ( 'should display first level parents - one expanded and one collapsed ' , function ( ) {
340+ it ( 'should be used for default expansion of nodes ' , function ( ) {
341341 expect ( element . find ( 'li:eq(0)' ) . hasClass ( 'tree-collapsed' ) ) . toBeTruthy ( ) ;
342342 expect ( element . find ( 'li:eq(1)' ) . hasClass ( 'tree-expanded' ) ) . toBeTruthy ( ) ;
343343 expect ( element . find ( 'li:eq(1) li:eq(0)' ) . hasClass ( 'tree-collapsed' ) ) . toBeTruthy ( ) ;
344344 expect ( element . find ( 'li:eq(1) li:eq(1)' ) . hasClass ( 'tree-expanded' ) ) . toBeTruthy ( ) ;
345345 } ) ;
346346
347+ it ( 'should update the tree as expandedNodes changes' , function ( ) {
348+ $rootScope . expandedNodes = [ $rootScope . treedata [ 0 ] ] ;
349+ $rootScope . $digest ( ) ;
350+ expect ( element . find ( 'li:eq(0)' ) . hasClass ( 'tree-expanded' ) ) . toBeTruthy ( ) ;
351+ expect ( element . find ( 'li:eq(1)' ) . hasClass ( 'tree-collapsed' ) ) . toBeTruthy ( ) ;
352+ } ) ;
353+
354+ it ( 'should add to expandedNodes expanding node' , function ( ) {
355+ element . find ( 'li:eq(0) .tree-branch-head' ) . click ( ) ;
356+ expect ( $rootScope . expandedNodes ) . toContain ( $rootScope . treedata [ 0 ] ) ;
357+ } ) ;
358+
359+ it ( 'should remove from expandedNodes collapsing node' , function ( ) {
360+ element . find ( 'li:eq(1) .tree-branch-head' ) . click ( ) ;
361+ expect ( $rootScope . expandedNodes ) . not . toContain ( $rootScope . treedata [ 1 ] ) ;
362+ } ) ;
363+
347364 it ( 'should retain expansions after full model refresh' , function ( ) {
348365 var testTree = createSubTree ( 2 , 2 ) ;
349366 $rootScope . treedata = angular . copy ( testTree ) ;
0 commit comments