@@ -54,7 +54,10 @@ describe('config argument', function() {
54
54
{ x : [ 1 , 2 , 3 ] , y : [ 3 , 2 , 1 ] }
55
55
] , {
56
56
width : 600 ,
57
- height : 400
57
+ height : 400 ,
58
+ annotations : [
59
+ { text : 'testing' , x : 1 , y : 1 , showarrow : true }
60
+ ]
58
61
} , { editable : true } )
59
62
. then ( done ) ;
60
63
} ) ;
@@ -78,6 +81,24 @@ describe('config argument', function() {
78
81
expect ( editBox . getAttribute ( 'contenteditable' ) ) . toBe ( 'true' ) ;
79
82
}
80
83
84
+ function checkIfDraggable ( elClass ) {
85
+ var el = document . getElementsByClassName ( elClass ) [ 0 ] ;
86
+
87
+ var elBox = el . getBoundingClientRect ( ) ,
88
+ elX = elBox . left + elBox . width / 2 ,
89
+ elY = elBox . top + elBox . height / 2 ;
90
+
91
+ mouseEvent ( 'mousedown' , elX , elY ) ;
92
+ mouseEvent ( 'mousemove' , elX - 20 , elY + 20 ) ;
93
+
94
+ var movedBox = el . getBoundingClientRect ( ) ;
95
+
96
+ expect ( movedBox . left ) . toBe ( elBox . left - 20 ) ;
97
+ expect ( movedBox . top ) . toBe ( elBox . top + 20 ) ;
98
+
99
+ mouseEvent ( 'mouseup' , elX - 20 , elY + 20 ) ;
100
+ }
101
+
81
102
it ( 'should make titles editable' , function ( ) {
82
103
checkIfEditable ( 'gtitle' , 'Click to enter Plot title' ) ;
83
104
} ) ;
@@ -94,22 +115,21 @@ describe('config argument', function() {
94
115
checkIfEditable ( 'legendtext' , 'trace 0' ) ;
95
116
} ) ;
96
117
97
- it ( 'should make legends draggable' , function ( ) {
98
-
99
- var legend = document . getElementsByClassName ( 'legend' ) [ 0 ] ,
100
- legendBox = legend . getBoundingClientRect ( ) ,
101
- legendX = legendBox . left + legendBox . width / 2 ,
102
- legendY = legendBox . top + legendBox . height / 2 ;
103
-
104
- mouseEvent ( 'mousedown' , legendX , legendY ) ;
105
- mouseEvent ( 'mousemove' , legendX - 20 , legendY + 20 ) ;
106
- mouseEvent ( 'mouseup' , legendX - 20 , legendY + 20 ) ;
118
+ it ( 'should make annotation labels editable' , function ( ) {
119
+ checkIfEditable ( 'annotation-text-g' , 'testing' ) ;
120
+ } ) ;
107
121
108
- var movedlegendBox = legend . getBoundingClientRect ( ) ;
122
+ it ( 'should make annotation labels draggable' , function ( ) {
123
+ checkIfDraggable ( 'annotation-text-g' ) ;
124
+ } ) ;
109
125
110
- expect ( movedlegendBox . left ) . not . toBe ( legendBox . left ) ;
111
- expect ( movedlegendBox . top ) . not . toBe ( legendBox . top ) ;
126
+ it ( 'should make annotation arrows draggable' , function ( ) {
127
+ checkIfDraggable ( 'annotation-arrow-g' ) ;
128
+ } ) ;
112
129
130
+ it ( 'should make legends draggable' , function ( ) {
131
+ checkIfDraggable ( 'legend' ) ;
113
132
} ) ;
133
+
114
134
} ) ;
115
135
} ) ;
0 commit comments