@@ -30,6 +30,10 @@ describe('dragElement', function() {
3030
3131 afterEach ( destroyGraphDiv ) ;
3232
33+ function countCoverSlip ( ) {
34+ return d3 . selectAll ( '.dragcover' ) . size ( ) ;
35+ }
36+
3337 it ( 'should init drag element' , function ( ) {
3438 var options = { element : this . element , gd : this . gd } ;
3539 dragElement . init ( options ) ;
@@ -103,10 +107,6 @@ describe('dragElement', function() {
103107 } ) ;
104108
105109 it ( 'should add a cover slip div to the DOM' , function ( ) {
106- function countCoverSlip ( ) {
107- return d3 . selectAll ( '.dragcover' ) . size ( ) ;
108- }
109-
110110 var options = { element : this . element , gd : this . gd } ;
111111 dragElement . init ( options ) ;
112112
@@ -122,6 +122,24 @@ describe('dragElement', function() {
122122 expect ( countCoverSlip ( ) ) . toEqual ( 0 ) ;
123123 } ) ;
124124
125+ it ( 'should not add a cover slip div to the DOM when right click' , function ( ) {
126+ var options = { element : this . element , gd : this . gd } ;
127+ dragElement . init ( options ) ;
128+
129+ var mockObj = {
130+ handleClick : function ( ) { }
131+ } ;
132+ spyOn ( mockObj , 'handleClick' ) ;
133+
134+ this . element . onclick = mockObj . handleClick ;
135+
136+ mouseEvent ( 'mousedown' , this . x , this . y , { buttons : 2 } ) ;
137+ expect ( countCoverSlip ( ) ) . toEqual ( 0 ) ;
138+
139+ mouseEvent ( 'mouseup' , this . x , this . y ) ;
140+ expect ( mockObj . handleClick ) . not . toHaveBeenCalled ( ) ;
141+ } ) ;
142+
125143 it ( 'should fire off click event when down/up without dragging' , function ( ) {
126144 var options = { element : this . element , gd : this . gd } ;
127145 dragElement . init ( options ) ;
0 commit comments