@@ -75,6 +75,24 @@ describe('treeControl', function() {
7575 } ) ;
7676 } ) ;
7777
78+ describe ( 'rendering context menu' , function ( ) {
79+ it ( 'should not render context-menu-id attributes if menu-id is not provided' , function ( ) {
80+ $rootScope . treedata = createSubTree ( 2 , 2 ) ;
81+ element = $compile ( '<treecontrol tree-model="treedata">{{node.label}}</treecontrol>' ) ( $rootScope ) ;
82+ $rootScope . $digest ( ) ;
83+ expect ( element . find ( 'div.tree-label:eq(0)' ) [ 0 ] . attributes [ 'context-menu-id' ] ) . toBeFalsy ( ) ;
84+ } ) ;
85+
86+ it ( 'should render context-menu-id attributes if menu-id is provided' , function ( ) {
87+
88+ $rootScope . treedata = createSubTree ( 2 , 2 ) ;
89+ element = $compile ( '<treecontrol tree-model="treedata" menu-id="ctxMenuId">{{node.label}}</treecontrol>' ) ( $rootScope ) ;
90+ $rootScope . $digest ( ) ;
91+ expect ( element . find ( 'div.tree-label:eq(0)' ) [ 0 ] . attributes [ 'context-menu-id' ] . value ) . toBe ( "ctxMenuId" ) ;
92+ } ) ;
93+ } ) ;
94+
95+
7896 describe ( 'customising using options.isLeaf' , function ( ) {
7997 it ( 'should display first level parents as collapsed nodes, including the leaf' , function ( ) {
8098 $rootScope . treedata = createSubTree ( 2 , 2 ) ;
@@ -192,38 +210,6 @@ describe('treeControl', function() {
192210 expect ( element . find ( 'li:eq(2) span' ) . text ( ) ) . toBe ( 'node 11 odd:false' ) ;
193211 expect ( element . find ( 'li:eq(3) span' ) . text ( ) ) . toBe ( 'node 16 odd:true' ) ;
194212 } ) ;
195-
196- it ( 'should not render context-menu-id attributes if menu-id is not provided' , function ( ) {
197-
198-
199- $rootScope . treedata = [
200- { label : "a" , children : [ ] } ,
201- { label : "c" , children : [ ] } ,
202- { label : "b" , children : [ ] }
203- ] ;
204- $rootScope . predicate = 'label' ;
205- $rootScope . reverse = true ;
206- element = $compile ( '<treecontrol tree-model="treedata">{{node.label}}</treecontrol>' ) ( $rootScope ) ;
207- $rootScope . $digest ( ) ;
208-
209- expect ( element . find ( 'div.tree-label:eq(0)' ) [ 0 ] . attributes [ 'ng-click' ] ) . toBeTruthy ( ) ;
210- expect ( element . find ( 'div.tree-label:eq(0)' ) [ 0 ] . attributes [ 'context-menu-id' ] ) . toBeFalsy ( ) ;
211- } ) ;
212-
213- it ( 'should render context-menu-id attributes if menu-id is provided' , function ( ) {
214-
215- $rootScope . treedata = [
216- { label : "a" , children : [ ] } ,
217- { label : "c" , children : [ ] } ,
218- { label : "b" , children : [ ] }
219- ] ;
220- $rootScope . predicate = 'label' ;
221- $rootScope . reverse = true ;
222- element = $compile ( '<treecontrol tree-model="treedata" menu-id="ctxMenuId">{{node.label}}</treecontrol>' ) ( $rootScope ) ;
223- $rootScope . $digest ( ) ;
224-
225- expect ( element . find ( 'div.tree-label:eq(0)' ) [ 0 ] . attributes [ 'context-menu-id' ] . value ) . toBe ( "ctxMenuId" ) ;
226- } ) ;
227213 } ) ;
228214
229215 describe ( 'selection' , function ( ) {
@@ -318,6 +304,18 @@ describe('treeControl', function() {
318304 } ) ;
319305 } ) ;
320306
307+ describe ( 'rightclick' , function ( ) {
308+ it ( 'should invoke right-click callback when item is right-clicked' , function ( ) {
309+
310+ $rootScope . treedata = createSubTree ( 2 , 2 ) ;
311+ element = $compile ( '<treecontrol tree-model="treedata" on-right-click="rightclick(node.label)">{{node.label}}</treecontrol>' ) ( $rootScope ) ;
312+ $rootScope . $digest ( ) ;
313+ $rootScope . rightclick = jasmine . createSpy ( 'rightclick' ) ;
314+ element . find ( 'li:eq(1) div' ) . triggerHandler ( 'contextmenu' ) ;
315+ expect ( $rootScope . rightclick ) . toHaveBeenCalledWith ( $rootScope . treedata [ 1 ] . label ) ;
316+ } ) ;
317+ } ) ;
318+
321319 describe ( 'toggle' , function ( ) {
322320 it ( 'should call on-node-toggle when node head is clicked with the expanding node and expanding indication' , function ( ) {
323321 $rootScope . treedata = createSubTree ( 2 , 2 ) ;
0 commit comments