@@ -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
@@ -123,15 +123,21 @@ describe('dragElement', function() {
123
123
} ) ;
124
124
125
125
it ( 'should not add a cover slip div to the DOM when right click' , function ( ) {
126
- function countCoverSlip ( ) {
127
- return d3 . selectAll ( '.dragcover' ) . size ( ) ;
128
- }
129
-
130
126
var options = { element : this . element , gd : this . gd } ;
131
127
dragElement . init ( options ) ;
132
128
129
+ var mockObj = {
130
+ handleClick : function ( ) { }
131
+ } ;
132
+ spyOn ( mockObj , 'handleClick' ) ;
133
+
134
+ this . element . onclick = mockObj . handleClick ;
135
+
133
136
mouseEvent ( 'mousedown' , this . x , this . y , { buttons : 2 } ) ;
134
137
expect ( countCoverSlip ( ) ) . toEqual ( 0 ) ;
138
+
139
+ mouseEvent ( 'mouseup' , this . x , this . y ) ;
140
+ expect ( mockObj . handleClick ) . not . toHaveBeenCalled ( ) ;
135
141
} ) ;
136
142
137
143
it ( 'should fire off click event when down/up without dragging' , function ( ) {
0 commit comments