@@ -30,6 +30,10 @@ describe('dragElement', function() {
30
30
31
31
afterEach ( destroyGraphDiv ) ;
32
32
33
+ function countCoverSlip ( ) {
34
+ return d3 . selectAll ( '.dragcover' ) . size ( ) ;
35
+ }
36
+
33
37
it ( 'should init drag element' , function ( ) {
34
38
var options = { element : this . element , gd : this . gd } ;
35
39
dragElement . init ( options ) ;
@@ -103,10 +107,6 @@ describe('dragElement', function() {
103
107
} ) ;
104
108
105
109
it ( 'should add a cover slip div to the DOM' , function ( ) {
106
- function countCoverSlip ( ) {
107
- return d3 . selectAll ( '.dragcover' ) . size ( ) ;
108
- }
109
-
110
110
var options = { element : this . element , gd : this . gd } ;
111
111
dragElement . init ( options ) ;
112
112
@@ -122,6 +122,24 @@ describe('dragElement', function() {
122
122
expect ( countCoverSlip ( ) ) . toEqual ( 0 ) ;
123
123
} ) ;
124
124
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
+
125
143
it ( 'should fire off click event when down/up without dragging' , function ( ) {
126
144
var options = { element : this . element , gd : this . gd } ;
127
145
dragElement . init ( options ) ;
0 commit comments