@@ -45,7 +45,11 @@ describe('svg+text utils', function() {
45
45
46
46
expect ( hasWrongAttr ) . toBe ( false ) ;
47
47
48
- expect ( a . attr ( 'style' ) ) . toBe ( 'cursor:pointer;' + ( style || '' ) ) ;
48
+ var fullStyle = style || '' ;
49
+ if ( style ) fullStyle += ';' ;
50
+ fullStyle += 'cursor:pointer' ;
51
+
52
+ expect ( a . attr ( 'style' ) ) . toBe ( fullStyle ) ;
49
53
}
50
54
51
55
function listAttributes ( node ) {
@@ -226,5 +230,50 @@ describe('svg+text utils', function() {
226
230
227
231
expect ( node . text ( ) ) . toEqual ( '100μ & < 10 > 0 100 × 20 ± 0.5 °' ) ;
228
232
} ) ;
233
+
234
+ it ( 'supports superscript by itself' , function ( ) {
235
+ var node = mockTextSVGElement ( '<sup>123</sup>' ) ;
236
+ expect ( node . html ( ) ) . toBe (
237
+ '<tspan style="font-size:70%" dy="-0.6em">123</tspan>' +
238
+ '<tspan dy="0.42em"></tspan>' ) ;
239
+ } ) ;
240
+
241
+ it ( 'supports subscript by itself' , function ( ) {
242
+ var node = mockTextSVGElement ( '<sub>123</sub>' ) ;
243
+ expect ( node . html ( ) ) . toBe (
244
+ '<tspan style="font-size:70%" dy="0.3em">123</tspan>' +
245
+ '<tspan dy="-0.21em"></tspan>' ) ;
246
+ } ) ;
247
+
248
+ it ( 'supports superscript and subscript together with normal text' , function ( ) {
249
+ var node = mockTextSVGElement ( 'SO<sub>4</sub><sup>2-</sup>' ) ;
250
+ expect ( node . html ( ) ) . toBe (
251
+ 'SO<tspan style="font-size:70%" dy="0.3em">4</tspan>' +
252
+ '<tspan dy="-0.21em"></tspan>' +
253
+ '<tspan style="font-size:70%" dy="-0.6em">2-</tspan>' +
254
+ '<tspan dy="0.42em"></tspan>' ) ;
255
+ } ) ;
256
+
257
+ it ( 'allows one <b> to span <br>s' , function ( ) {
258
+ var node = mockTextSVGElement ( 'be <b>Bold<br>and<br><i>Strong</i></b>' ) ;
259
+ expect ( node . html ( ) ) . toBe (
260
+ '<tspan class="line" dy="0em">be ' +
261
+ '<tspan style="font-weight:bold">Bold</tspan></tspan>' +
262
+ '<tspan class="line" dy="1.3em">' +
263
+ '<tspan style="font-weight:bold">and</tspan></tspan>' +
264
+ '<tspan class="line" dy="2.6em">' +
265
+ '<tspan style="font-weight:bold">' +
266
+ '<tspan style="font-style:italic">Strong</tspan></tspan></tspan>' ) ;
267
+ } ) ;
268
+
269
+ it ( 'allows one <sub> to span <br>s' , function ( ) {
270
+ var node = mockTextSVGElement ( 'SO<sub>4<br>44</sub>' ) ;
271
+ expect ( node . html ( ) ) . toBe (
272
+ '<tspan class="line" dy="0em">SO' +
273
+ '<tspan style="font-size:70%" dy="0.3em">4</tspan></tspan>' +
274
+ '<tspan class="line" dy="1.3em">' +
275
+ '<tspan style="font-size:70%" dy="0.3em">44</tspan>' +
276
+ '<tspan dy="-0.21em"></tspan></tspan>' ) ;
277
+ } ) ;
229
278
} ) ;
230
279
} ) ;
0 commit comments