@@ -36,7 +36,7 @@ module.exports = {
36
36
editor = this . editor ;
37
37
next ( ) ;
38
38
} ,
39
-
39
+
40
40
"test: gutter error tooltip" : function ( ) {
41
41
var editor = this . editor ;
42
42
var value = "" ;
@@ -51,15 +51,13 @@ module.exports = {
51
51
assert . ok ( / a c e _ e r r o r / . test ( annotation . className ) ) ;
52
52
53
53
var rect = annotation . getBoundingClientRect ( ) ;
54
- annotation . dispatchEvent ( new MouseEvent ( "move" , { clientX : rect . left , clientY : rect . top } ) ) ;
54
+ annotation . dispatchEvent ( new MouseEvent ( "move" , { x : rect . left , y : rect . top } ) ) ;
55
55
56
56
// Wait for the tooltip to appear after its timeout.
57
57
setTimeout ( function ( ) {
58
58
editor . renderer . $loop . _flush ( ) ;
59
- var tooltipHeader = editor . container . querySelector ( ".ace_gutter-tooltip_header" ) ;
60
- var tooltipBody = editor . container . querySelector ( ".ace_gutter-tooltip_body" ) ;
61
- assert . ok ( / 1 e r r o r / . test ( tooltipHeader . textContent ) ) ;
62
- assert . ok ( / e r r o r t e s t / . test ( tooltipBody . textContent ) ) ;
59
+ var tooltip = editor . container . querySelector ( ".ace_tooltip" ) ;
60
+ assert . ok ( / e r r o r t e s t / . test ( tooltip . textContent ) ) ;
63
61
} , 100 ) ;
64
62
} ,
65
63
"test: gutter warning tooltip" : function ( ) {
@@ -76,15 +74,13 @@ module.exports = {
76
74
assert . ok ( / a c e _ w a r n i n g / . test ( annotation . className ) ) ;
77
75
78
76
var rect = annotation . getBoundingClientRect ( ) ;
79
- annotation . dispatchEvent ( new MouseEvent ( "move" , { clientX : rect . left , clientY : rect . top } ) ) ;
77
+ annotation . dispatchEvent ( new MouseEvent ( "move" , { x : rect . left , y : rect . top } ) ) ;
80
78
81
79
// Wait for the tooltip to appear after its timeout.
82
80
setTimeout ( function ( ) {
83
81
editor . renderer . $loop . _flush ( ) ;
84
- var tooltipHeader = editor . container . querySelector ( ".ace_gutter-tooltip_header" ) ;
85
- var tooltipBody = editor . container . querySelector ( ".ace_gutter-tooltip_body" ) ;
86
- assert . ok ( / 1 w a r n i n g / . test ( tooltipHeader . textContent ) ) ;
87
- assert . ok ( / w a r n i n g t e s t / . test ( tooltipBody . textContent ) ) ;
82
+ var tooltip = editor . container . querySelector ( ".ace_tooltip" ) ;
83
+ assert . ok ( / w a r n i n g t e s t / . test ( tooltip . textContent ) ) ;
88
84
} , 100 ) ;
89
85
} ,
90
86
"test: gutter info tooltip" : function ( ) {
@@ -101,15 +97,13 @@ module.exports = {
101
97
assert . ok ( / a c e _ i n f o / . test ( annotation . className ) ) ;
102
98
103
99
var rect = annotation . getBoundingClientRect ( ) ;
104
- annotation . dispatchEvent ( new MouseEvent ( "move" , { clientX : rect . left , clientY : rect . top } ) ) ;
100
+ annotation . dispatchEvent ( new MouseEvent ( "move" , { x : rect . left , y : rect . top } ) ) ;
105
101
106
102
// Wait for the tooltip to appear after its timeout.
107
103
setTimeout ( function ( ) {
108
104
editor . renderer . $loop . _flush ( ) ;
109
- var tooltipHeader = editor . container . querySelector ( ".ace_gutter-tooltip_header" ) ;
110
- var tooltipBody = editor . container . querySelector ( ".ace_gutter-tooltip_body" ) ;
111
- assert . ok ( / 1 i n f o r m a t i o n m e s s a g e / . test ( tooltipHeader . textContent ) ) ;
112
- assert . ok ( / i n f o t e s t / . test ( tooltipBody . textContent ) ) ;
105
+ var tooltip = editor . container . querySelector ( ".ace_tooltip" ) ;
106
+ assert . ok ( / i n f o t e s t / . test ( tooltip . textContent ) ) ;
113
107
} , 100 ) ;
114
108
} ,
115
109
"test: gutter svg icons" : function ( ) {
@@ -129,15 +123,108 @@ module.exports = {
129
123
var annotation = line . children [ 2 ] ;
130
124
assert . ok ( / a c e _ i c o n _ s v g / . test ( annotation . className ) ) ;
131
125
} ,
132
-
133
-
126
+ "test: error show up in fold" : function ( ) {
127
+ var editor = this . editor ;
128
+ var value = "x {" + "\n" . repeat ( 50 ) + "}" ;
129
+ value = value . repeat ( 50 ) ;
130
+ editor . session . setMode ( new Mode ( ) ) ;
131
+ editor . setOption ( "showFoldedAnnotations" , true ) ;
132
+ editor . setValue ( value , - 1 ) ;
133
+ editor . session . setAnnotations ( [ { row : 1 , column : 0 , type : "error" , text : "error test" } ] ) ;
134
+ editor . renderer . $loop . _flush ( ) ;
135
+
136
+ // Fold the line containing the annotation.
137
+ var lines = editor . renderer . $gutterLayer . $lines ;
138
+ assert . equal ( lines . cells [ 1 ] . element . textContent , "2" ) ;
139
+ var toggler = lines . cells [ 0 ] . element . children [ 1 ] ;
140
+ var rect = toggler . getBoundingClientRect ( ) ;
141
+ if ( ! rect . left ) rect . left = 100 ; // for mockdom
142
+ toggler . dispatchEvent ( MouseEvent ( "click" , { x : rect . left , y : rect . top } ) ) ;
143
+ editor . renderer . $loop . _flush ( ) ;
144
+ assert . ok ( / a c e _ c l o s e d / . test ( toggler . className ) ) ;
145
+ assert . equal ( lines . cells [ 1 ] . element . textContent , "51" ) ;
146
+
147
+ // Annotation node should have fold class.
148
+ var annotation = lines . cells [ 0 ] . element . children [ 2 ] ;
149
+ assert . ok ( / a c e _ e r r o r _ f o l d / . test ( annotation . className ) ) ;
150
+
151
+ var rect = annotation . getBoundingClientRect ( ) ;
152
+ annotation . dispatchEvent ( new MouseEvent ( "move" , { x : rect . left , y : rect . top } ) ) ;
153
+
154
+ // Wait for the tooltip to appear after its timeout.
155
+ setTimeout ( function ( ) {
156
+ editor . renderer . $loop . _flush ( ) ;
157
+ var tooltip = editor . container . querySelector ( ".ace_tooltip" ) ;
158
+ assert . ok ( / e r r o r i n f o l d e d / . test ( tooltip . textContent ) ) ;
159
+ } , 100 ) ;
160
+ } ,
161
+ "test: warning show up in fold" : function ( ) {
162
+ var editor = this . editor ;
163
+ var value = "x {" + "\n" . repeat ( 50 ) + "}" ;
164
+ value = value . repeat ( 50 ) ;
165
+ editor . session . setMode ( new Mode ( ) ) ;
166
+ editor . setOption ( "showFoldedAnnotations" , true ) ;
167
+ editor . setValue ( value , - 1 ) ;
168
+ editor . session . setAnnotations ( [ { row : 1 , column : 0 , type : "warning" , text : "warning test" } ] ) ;
169
+ editor . renderer . $loop . _flush ( ) ;
170
+
171
+ // Fold the line containing the annotation.
172
+ var lines = editor . renderer . $gutterLayer . $lines ;
173
+ assert . equal ( lines . cells [ 1 ] . element . textContent , "2" ) ;
174
+ var toggler = lines . cells [ 0 ] . element . children [ 1 ] ;
175
+ var rect = toggler . getBoundingClientRect ( ) ;
176
+ if ( ! rect . left ) rect . left = 100 ; // for mockdom
177
+ toggler . dispatchEvent ( MouseEvent ( "click" , { x : rect . left , y : rect . top } ) ) ;
178
+ editor . renderer . $loop . _flush ( ) ;
179
+ assert . ok ( / a c e _ c l o s e d / . test ( toggler . className ) ) ;
180
+ assert . equal ( lines . cells [ 1 ] . element . textContent , "51" ) ;
181
+
182
+ // Annotation node should have fold class.
183
+ var annotation = lines . cells [ 0 ] . element . children [ 2 ] ;
184
+ assert . ok ( / a c e _ w a r n i n g _ f o l d / . test ( annotation . className ) ) ;
185
+
186
+ var rect = annotation . getBoundingClientRect ( ) ;
187
+ annotation . dispatchEvent ( new MouseEvent ( "move" , { x : rect . left , y : rect . top } ) ) ;
188
+
189
+ // Wait for the tooltip to appear after its timeout.
190
+ setTimeout ( function ( ) {
191
+ editor . renderer . $loop . _flush ( ) ;
192
+ var tooltip = editor . container . querySelector ( ".ace_tooltip" ) ;
193
+ assert . ok ( / w a r n i n g i n f o l d e d / . test ( tooltip . textContent ) ) ;
194
+ } , 100 ) ;
195
+ } ,
196
+ "test: info not show up in fold" : function ( ) {
197
+ var editor = this . editor ;
198
+ var value = "x {" + "\n" . repeat ( 50 ) + "}" ;
199
+ value = value . repeat ( 50 ) ;
200
+ editor . session . setMode ( new Mode ( ) ) ;
201
+ editor . setOption ( "showFoldedAnnotations" , true ) ;
202
+ editor . setValue ( value , - 1 ) ;
203
+ editor . session . setAnnotations ( [ { row : 1 , column : 0 , type : "info" , text : "info test" } ] ) ;
204
+ editor . renderer . $loop . _flush ( ) ;
205
+
206
+ // Fold the line containing the annotation.
207
+ var lines = editor . renderer . $gutterLayer . $lines ;
208
+ assert . equal ( lines . cells [ 1 ] . element . textContent , "2" ) ;
209
+ var toggler = lines . cells [ 0 ] . element . children [ 1 ] ;
210
+ var rect = toggler . getBoundingClientRect ( ) ;
211
+ if ( ! rect . left ) rect . left = 100 ; // for mockdom
212
+ toggler . dispatchEvent ( MouseEvent ( "click" , { x : rect . left , y : rect . top } ) ) ;
213
+ editor . renderer . $loop . _flush ( ) ;
214
+ assert . ok ( / a c e _ c l o s e d / . test ( toggler . className ) ) ;
215
+ assert . equal ( lines . cells [ 1 ] . element . textContent , "51" ) ;
216
+
217
+ // Annotation node should NOT have fold class.
218
+ var annotation = lines . cells [ 0 ] . element . children [ 2 ] ;
219
+ assert . notOk ( / f o l d / . test ( annotation . className ) ) ;
220
+ } ,
221
+
134
222
tearDown : function ( ) {
135
223
this . editor . destroy ( ) ;
136
224
document . body . removeChild ( this . editor . container ) ;
137
225
}
138
226
} ;
139
227
140
-
141
228
if ( typeof module !== "undefined" && module === require . main ) {
142
229
require ( "asyncjs" ) . test . testcase ( module . exports ) . exec ( ) ;
143
230
}
0 commit comments