Index: trunk/extensions/VisualEditor/tests/es/es.DocumentNode.test.js |
— | — | @@ -60,37 +60,62 @@ |
61 | 61 | } |
62 | 62 | } ); |
63 | 63 | |
64 | | -test( 'es.DocumentBranchNode.getNodeFromOffset', 22, function() { |
| 64 | +test( 'es.DocumentBranchNode.getNodeFromOffset', 23, function() { |
65 | 65 | // Tests 1 .. 22 |
66 | 66 | var getNodeFromOffsetTests = [ |
| 67 | + // Test 1 - |[<a></a><b> </b><c> </c><d> </d><e> </e>] |
67 | 68 | { 'input': -1, 'output': null }, |
68 | | - { 'input': 0, 'output': a }, |
| 69 | + // Test 2 - [|<a></a><b> </b><c> </c><d> </d><e> </e>] |
| 70 | + { 'input': 0, 'output': root1 }, |
| 71 | + // Test 3 - [<a>|</a><b> </b><c> </c><d> </d><e> </e>] |
69 | 72 | { 'input': 1, 'output': a }, |
70 | | - { 'input': 2, 'output': b }, |
| 73 | + // Test 4 - [<a></a>|<b> </b><c> </c><d> </d><e> </e>] |
| 74 | + { 'input': 2, 'output': root1 }, |
| 75 | + // Test 5 - [<a></a><b>| </b><c> </c><d> </d><e> </e>] |
71 | 76 | { 'input': 3, 'output': b }, |
| 77 | + // Test 6 - [<a></a><b> |</b><c> </c><d> </d><e> </e>] |
72 | 78 | { 'input': 4, 'output': b }, |
73 | | - { 'input': 5, 'output': c }, |
| 79 | + // Test 7 - [<a></a><b> </b>|<c> </c><d> </d><e> </e>] |
| 80 | + { 'input': 5, 'output': root1 }, |
| 81 | + // Test 8 - [<a></a><b> </b><c>| </c><d> </d><e> </e>] |
74 | 82 | { 'input': 6, 'output': c }, |
| 83 | + // Test 9 - [<a></a><b> </b><c> | </c><d> </d><e> </e>] |
75 | 84 | { 'input': 7, 'output': c }, |
| 85 | + // Test 10 - [<a></a><b> </b><c> |</c><d> </d><e> </e>] |
76 | 86 | { 'input': 8, 'output': c }, |
77 | | - { 'input': 9, 'output': d }, |
| 87 | + // Test 11 - [<a></a><b> </b><c> </c>|<d> </d><e> </e>] |
| 88 | + { 'input': 9, 'output': root1 }, |
| 89 | + // Test 12 - [<a></a><b> </b><c> </c><d>| </d><e> </e>] |
78 | 90 | { 'input': 10, 'output': d }, |
| 91 | + // Test 13 - [<a></a><b> </b><c> </c><d> | </d><e> </e>] |
79 | 92 | { 'input': 11, 'output': d }, |
| 93 | + // Test 14 - [<a></a><b> </b><c> </c><d> | </d><e> </e>] |
80 | 94 | { 'input': 12, 'output': d }, |
| 95 | + // Test 15 - [<a></a><b> </b><c> </c><d> |</d><e> </e>] |
81 | 96 | { 'input': 13, 'output': d }, |
82 | | - { 'input': 14, 'output': e }, |
| 97 | + // Test 16 - [<a></a><b> </b><c> </c><d> </d>|<e> </e>] |
| 98 | + { 'input': 14, 'output': root1 }, |
| 99 | + // Test 17 - [<a></a><b> </b><c> </c><d> </d><e>| </e>] |
83 | 100 | { 'input': 15, 'output': e }, |
| 101 | + // Test 18 - [<a></a><b> </b><c> </c><d> </d><e> | </e>] |
84 | 102 | { 'input': 16, 'output': e }, |
| 103 | + // Test 19 - [<a></a><b> </b><c> </c><d> </d><e> | </e>] |
85 | 104 | { 'input': 17, 'output': e }, |
| 105 | + // Test 20 - [<a></a><b> </b><c> </c><d> </d><e> | </e>] |
86 | 106 | { 'input': 18, 'output': e }, |
| 107 | + // Test 21 - [<a></a><b> </b><c> </c><d> </d><e> |</e>] |
87 | 108 | { 'input': 19, 'output': e }, |
88 | | - { 'input': 20, 'output': null } |
| 109 | + // Test 22 - [<a></a><b> </b><c> </c><d> </d><e> </e>|] |
| 110 | + { 'input': 20, 'output': root1 }, |
| 111 | + // Test 22 - [<a></a><b> </b><c> </c><d> </d><e> </e>]| |
| 112 | + { 'input': 21, 'output': null } |
89 | 113 | ]; |
90 | 114 | for ( var i = 0; i < getNodeFromOffsetTests.length; i++ ) { |
91 | | - strictEqual( |
92 | | - root1.getNodeFromOffset( getNodeFromOffsetTests[i].input ), |
| 115 | + ok( |
| 116 | + root1.getNodeFromOffset( getNodeFromOffsetTests[i].input ) === |
93 | 117 | getNodeFromOffsetTests[i].output, |
94 | | - 'getNodeFromOffset finds the right item or returns null when out of range' |
| 118 | + 'getNodeFromOffset finds the right item or returns null when out of range ' + |
| 119 | + '(' + getNodeFromOffsetTests[i].input + ')' |
95 | 120 | ); |
96 | 121 | } |
97 | 122 | } ); |
— | — | @@ -137,109 +162,130 @@ |
138 | 163 | // * past end |
139 | 164 | var selectNodesTests = [ |
140 | 165 | // Complete set of combinations within the same node: |
| 166 | + |
| 167 | + // Test 1 |
141 | 168 | { |
142 | 169 | 'node': root2, |
143 | 170 | 'input': new es.Range( 0, 0 ), |
144 | 171 | 'output': [], |
145 | 172 | 'desc': 'Zero-length range before the beginning of a node' |
146 | 173 | }, |
| 174 | + // Test 2 |
147 | 175 | { |
148 | 176 | 'node': root2, |
149 | 177 | 'input': new es.Range( 0, 1 ), |
150 | 178 | 'output': [{ 'node': f, 'range': new es.Range( 0, 0 ) }], |
151 | 179 | 'desc': 'Range starting before the beginning of a node and ending at the beginning' |
152 | 180 | }, |
| 181 | + // Test 3 |
153 | 182 | { |
154 | 183 | 'node': root2, |
155 | 184 | 'input': new es.Range( 10, 15 ), |
156 | 185 | 'output': [{ 'node': g, 'range': new es.Range( 0, 4 ) }], |
157 | 186 | 'desc': 'Range starting before the beginning of a node and ending in the middle' |
158 | 187 | }, |
| 188 | + // Test 4 |
159 | 189 | { |
160 | 190 | 'node': root2, |
161 | 191 | 'input': new es.Range( 20, 29 ), |
162 | 192 | 'output': [{ 'node': h, 'range': new es.Range( 0, 8 ) }], |
163 | 193 | 'desc': 'Range starting before the beginning of a node and ending at the end' |
164 | 194 | }, |
| 195 | + // Test 5 |
165 | 196 | { |
166 | 197 | 'node': root2, |
167 | 198 | 'input': new es.Range( 0, 10 ), |
168 | 199 | 'output': [{ 'node': f } ], |
169 | 200 | 'desc': 'Range starting before the beginning of a node and ending past the end' |
170 | 201 | }, |
| 202 | + // Test 6 |
171 | 203 | { |
172 | 204 | 'node': root2, |
173 | 205 | 'input': new es.Range( 11, 11 ), |
174 | 206 | 'output': [{ 'node': g, 'range': new es.Range( 0, 0 ) }], |
175 | 207 | 'desc': 'Zero-length range at the beginning of a node' |
176 | 208 | }, |
| 209 | + // Test 7 |
177 | 210 | { |
178 | 211 | 'node': root2, |
179 | 212 | 'input': new es.Range( 21, 26 ), |
180 | 213 | 'output': [{ 'node': h, 'range': new es.Range( 0, 5 ) }], |
181 | 214 | 'desc': 'Range starting at the beginning of a node and ending in the middle' |
182 | 215 | }, |
| 216 | + // Test 8 |
183 | 217 | { |
184 | 218 | 'node': root2, |
185 | 219 | 'input': new es.Range( 1, 9 ), |
186 | 220 | 'output': [{ 'node': f, 'range': new es.Range( 0, 8 ) }], |
187 | 221 | 'desc': 'Range starting at the beginning of a node and ending at the end' |
188 | 222 | }, |
| 223 | + // Test 9 |
189 | 224 | { |
190 | 225 | 'node': root2, |
191 | 226 | 'input': new es.Range( 11, 20 ), |
192 | 227 | 'output': [{ 'node': g, 'range': new es.Range( 0, 8 ) }], |
193 | 228 | 'desc': 'Range starting at the beginning of a node and ending past the end' |
194 | 229 | }, |
| 230 | + // Test 10 |
195 | 231 | { |
196 | 232 | 'node': root2, |
197 | 233 | 'input': new es.Range( 22, 22 ), |
198 | 234 | 'output': [{ 'node': h, 'range': new es.Range( 1, 1 ) }], |
199 | 235 | 'desc': 'Zero-length range in the middle of a node' |
200 | 236 | }, |
| 237 | + // Test 11 |
201 | 238 | { |
202 | 239 | 'node': root2, |
203 | 240 | 'input': new es.Range( 2, 7 ), |
204 | 241 | 'output': [{ 'node': f, 'range': new es.Range( 1, 6 ) }], |
205 | 242 | 'desc': 'Range starting and ending in the middle of the same node' |
206 | 243 | }, |
| 244 | + // Test 12 |
207 | 245 | { |
208 | 246 | 'node': root2, |
209 | 247 | 'input': new es.Range( 13, 19 ), |
210 | 248 | 'output': [{ 'node': g, 'range': new es.Range( 2, 8 ) }], |
211 | 249 | 'desc': 'Range starting in the middle of a node and ending at the end' |
212 | 250 | }, |
| 251 | + // Test 13 |
213 | 252 | { |
214 | 253 | 'node': root2, |
215 | 254 | 'input': new es.Range( 24, 30 ), |
216 | 255 | 'output': [{ 'node': h, 'range': new es.Range( 3, 8 ) }], |
217 | 256 | 'desc': 'Range starting in the middle of a node and ending past the end' |
218 | 257 | }, |
| 258 | + // Test 14 |
219 | 259 | { |
220 | 260 | 'node': root2, |
221 | 261 | 'input': new es.Range( 9, 9 ), |
222 | 262 | 'output': [{ 'node': f, 'range': new es.Range( 8, 8 ) }], |
223 | 263 | 'desc': 'Zero-length range at the end of a node' |
224 | 264 | }, |
| 265 | + // Test 15 |
225 | 266 | { |
226 | 267 | 'node': root2, |
227 | 268 | 'input': new es.Range( 19, 20 ), |
228 | 269 | 'output': [{ 'node': g, 'range': new es.Range( 8, 8 ) }], |
229 | 270 | 'desc': 'Range starting at the end of a node and ending past the end' |
230 | 271 | }, |
| 272 | + // Test 16 |
231 | 273 | { |
232 | 274 | 'node': root2, |
233 | 275 | 'input': new es.Range( 30, 30 ), |
234 | 276 | 'output': [], |
235 | 277 | 'desc': 'Zero-length range past the end of a node' |
236 | 278 | }, |
| 279 | + // Test 17 |
237 | 280 | { |
238 | 281 | 'node': root2, |
239 | 282 | 'input': new es.Range( 20, 20 ), |
240 | 283 | 'output': [], |
241 | 284 | 'desc': 'Zero-length range between two nodes' |
242 | 285 | }, |
| 286 | + |
243 | 287 | // Complete set of combinations for cross-node selections. Generated with help of a script |
| 288 | + |
| 289 | + // Test 18 |
244 | 290 | { |
245 | 291 | 'node': root2, |
246 | 292 | 'input': new es.Range( 0, 11 ), |
— | — | @@ -249,6 +295,7 @@ |
250 | 296 | ], |
251 | 297 | 'desc': 'Range starting before the beginning of the first node and ending at the beginning of the second node' |
252 | 298 | }, |
| 299 | + // Test 19 |
253 | 300 | { |
254 | 301 | 'node': root2, |
255 | 302 | 'input': new es.Range( 0, 14 ), |
— | — | @@ -258,6 +305,7 @@ |
259 | 306 | ], |
260 | 307 | 'desc': 'Range starting before the beginning of the first node and ending in the middle of the second node' |
261 | 308 | }, |
| 309 | + // Test 20 |
262 | 310 | { |
263 | 311 | 'node': root2, |
264 | 312 | 'input': new es.Range( 0, 19 ), |
— | — | @@ -267,6 +315,7 @@ |
268 | 316 | ], |
269 | 317 | 'desc': 'Range starting before the beginning of the first node and ending at the end of the second node' |
270 | 318 | }, |
| 319 | + // Test 21 |
271 | 320 | { |
272 | 321 | 'node': root2, |
273 | 322 | 'input': new es.Range( 0, 20 ), |
— | — | @@ -276,6 +325,7 @@ |
277 | 326 | ], |
278 | 327 | 'desc': 'Range starting before the beginning of the first node and ending between the second and the third node' |
279 | 328 | }, |
| 329 | + // Test 22 |
280 | 330 | { |
281 | 331 | 'node': root2, |
282 | 332 | 'input': new es.Range( 0, 21 ), |
— | — | @@ -286,6 +336,7 @@ |
287 | 337 | ], |
288 | 338 | 'desc': 'Range starting before the beginning of the first node and ending at the beginning of the third node' |
289 | 339 | }, |
| 340 | + // Test 23 |
290 | 341 | { |
291 | 342 | 'node': root2, |
292 | 343 | 'input': new es.Range( 0, 27 ), |
— | — | @@ -296,6 +347,7 @@ |
297 | 348 | ], |
298 | 349 | 'desc': 'Range starting before the beginning of the first node and ending in the middle of the third node' |
299 | 350 | }, |
| 351 | + // Test 24 |
300 | 352 | { |
301 | 353 | 'node': root2, |
302 | 354 | 'input': new es.Range( 0, 29 ), |
— | — | @@ -306,6 +358,7 @@ |
307 | 359 | ], |
308 | 360 | 'desc': 'Range starting before the beginning of the first node and ending at the end of the third node' |
309 | 361 | }, |
| 362 | + // Test 25 |
310 | 363 | { |
311 | 364 | 'node': root2, |
312 | 365 | 'input': new es.Range( 0, 30 ), |
— | — | @@ -316,6 +369,7 @@ |
317 | 370 | ], |
318 | 371 | 'desc': 'Range starting before the beginning of the first node and ending past the end of the third node' |
319 | 372 | }, |
| 373 | + // Test 26 |
320 | 374 | { |
321 | 375 | 'node': root2, |
322 | 376 | 'input': new es.Range( 1, 11 ), |
— | — | @@ -325,6 +379,7 @@ |
326 | 380 | ], |
327 | 381 | 'desc': 'Range starting at the beginning of the first node and ending at the beginning of the second node' |
328 | 382 | }, |
| 383 | + // Test 27 |
329 | 384 | { |
330 | 385 | 'node': root2, |
331 | 386 | 'input': new es.Range( 1, 14 ), |
— | — | @@ -334,6 +389,7 @@ |
335 | 390 | ], |
336 | 391 | 'desc': 'Range starting at the beginning of the first node and ending in the middle of the second node' |
337 | 392 | }, |
| 393 | + // Test 28 |
338 | 394 | { |
339 | 395 | 'node': root2, |
340 | 396 | 'input': new es.Range( 1, 19 ), |
— | — | @@ -343,6 +399,7 @@ |
344 | 400 | ], |
345 | 401 | 'desc': 'Range starting at the beginning of the first node and ending at the end of the second node' |
346 | 402 | }, |
| 403 | + // Test 29 |
347 | 404 | { |
348 | 405 | 'node': root2, |
349 | 406 | 'input': new es.Range( 1, 20 ), |
— | — | @@ -352,6 +409,7 @@ |
353 | 410 | ], |
354 | 411 | 'desc': 'Range starting at the beginning of the first node and ending between the second and the third node' |
355 | 412 | }, |
| 413 | + // Test 30 |
356 | 414 | { |
357 | 415 | 'node': root2, |
358 | 416 | 'input': new es.Range( 1, 21 ), |
— | — | @@ -362,6 +420,7 @@ |
363 | 421 | ], |
364 | 422 | 'desc': 'Range starting at the beginning of the first node and ending at the beginning of the third node' |
365 | 423 | }, |
| 424 | + // Test 31 |
366 | 425 | { |
367 | 426 | 'node': root2, |
368 | 427 | 'input': new es.Range( 1, 27 ), |
— | — | @@ -372,6 +431,7 @@ |
373 | 432 | ], |
374 | 433 | 'desc': 'Range starting at the beginning of the first node and ending in the middle of the third node' |
375 | 434 | }, |
| 435 | + // Test 32 |
376 | 436 | { |
377 | 437 | 'node': root2, |
378 | 438 | 'input': new es.Range( 1, 29 ), |
— | — | @@ -382,6 +442,7 @@ |
383 | 443 | ], |
384 | 444 | 'desc': 'Range starting at the beginning of the first node and ending at the end of the third node' |
385 | 445 | }, |
| 446 | + // Test 33 |
386 | 447 | { |
387 | 448 | 'node': root2, |
388 | 449 | 'input': new es.Range( 1, 30 ), |
— | — | @@ -392,6 +453,7 @@ |
393 | 454 | ], |
394 | 455 | 'desc': 'Range starting at the beginning of the first node and ending past the end of the third node' |
395 | 456 | }, |
| 457 | + // Test 34 |
396 | 458 | { |
397 | 459 | 'node': root2, |
398 | 460 | 'input': new es.Range( 5, 11 ), |
— | — | @@ -401,6 +463,7 @@ |
402 | 464 | ], |
403 | 465 | 'desc': 'Range starting in the middle of the first node and ending at the beginning of the second node' |
404 | 466 | }, |
| 467 | + // Test 35 |
405 | 468 | { |
406 | 469 | 'node': root2, |
407 | 470 | 'input': new es.Range( 5, 14 ), |
— | — | @@ -410,6 +473,7 @@ |
411 | 474 | ], |
412 | 475 | 'desc': 'Range starting in the middle of the first node and ending in the middle of the second node' |
413 | 476 | }, |
| 477 | + // Test 36 |
414 | 478 | { |
415 | 479 | 'node': root2, |
416 | 480 | 'input': new es.Range( 5, 19 ), |
— | — | @@ -419,6 +483,7 @@ |
420 | 484 | ], |
421 | 485 | 'desc': 'Range starting in the middle of the first node and ending at the end of the second node' |
422 | 486 | }, |
| 487 | + // Test 37 |
423 | 488 | { |
424 | 489 | 'node': root2, |
425 | 490 | 'input': new es.Range( 5, 20 ), |
— | — | @@ -428,6 +493,7 @@ |
429 | 494 | ], |
430 | 495 | 'desc': 'Range starting in the middle of the first node and ending between the second and the third node' |
431 | 496 | }, |
| 497 | + // Test 38 |
432 | 498 | { |
433 | 499 | 'node': root2, |
434 | 500 | 'input': new es.Range( 5, 21 ), |
— | — | @@ -438,6 +504,7 @@ |
439 | 505 | ], |
440 | 506 | 'desc': 'Range starting in the middle of the first node and ending at the beginning of the third node' |
441 | 507 | }, |
| 508 | + // Test 39 |
442 | 509 | { |
443 | 510 | 'node': root2, |
444 | 511 | 'input': new es.Range( 5, 27 ), |
— | — | @@ -448,6 +515,7 @@ |
449 | 516 | ], |
450 | 517 | 'desc': 'Range starting in the middle of the first node and ending in the middle of the third node' |
451 | 518 | }, |
| 519 | + // Test 40 |
452 | 520 | { |
453 | 521 | 'node': root2, |
454 | 522 | 'input': new es.Range( 5, 29 ), |
— | — | @@ -458,6 +526,7 @@ |
459 | 527 | ], |
460 | 528 | 'desc': 'Range starting in the middle of the first node and ending at the end of the third node' |
461 | 529 | }, |
| 530 | + // Test 41 |
462 | 531 | { |
463 | 532 | 'node': root2, |
464 | 533 | 'input': new es.Range( 5, 30 ), |
— | — | @@ -468,6 +537,7 @@ |
469 | 538 | ], |
470 | 539 | 'desc': 'Range starting in the middle of the first node and ending past the end of the third node' |
471 | 540 | }, |
| 541 | + // Test 42 |
472 | 542 | { |
473 | 543 | 'node': root2, |
474 | 544 | 'input': new es.Range( 9, 11 ), |
— | — | @@ -477,6 +547,7 @@ |
478 | 548 | ], |
479 | 549 | 'desc': 'Range starting at the end of the first node and ending at the beginning of the second node' |
480 | 550 | }, |
| 551 | + // Test 43 |
481 | 552 | { |
482 | 553 | 'node': root2, |
483 | 554 | 'input': new es.Range( 9, 14 ), |
— | — | @@ -486,6 +557,7 @@ |
487 | 558 | ], |
488 | 559 | 'desc': 'Range starting at the end of the first node and ending in the middle of the second node' |
489 | 560 | }, |
| 561 | + // Test 44 |
490 | 562 | { |
491 | 563 | 'node': root2, |
492 | 564 | 'input': new es.Range( 9, 19 ), |
— | — | @@ -495,6 +567,7 @@ |
496 | 568 | ], |
497 | 569 | 'desc': 'Range starting at the end of the first node and ending at the end of the second node' |
498 | 570 | }, |
| 571 | + // Test 45 |
499 | 572 | { |
500 | 573 | 'node': root2, |
501 | 574 | 'input': new es.Range( 9, 20 ), |
— | — | @@ -504,6 +577,7 @@ |
505 | 578 | ], |
506 | 579 | 'desc': 'Range starting at the end of the first node and ending between the second and the third node' |
507 | 580 | }, |
| 581 | + // Test 46 |
508 | 582 | { |
509 | 583 | 'node': root2, |
510 | 584 | 'input': new es.Range( 9, 21 ), |
— | — | @@ -514,6 +588,7 @@ |
515 | 589 | ], |
516 | 590 | 'desc': 'Range starting at the end of the first node and ending at the beginning of the third node' |
517 | 591 | }, |
| 592 | + // Test 47 |
518 | 593 | { |
519 | 594 | 'node': root2, |
520 | 595 | 'input': new es.Range( 9, 27 ), |
— | — | @@ -524,6 +599,7 @@ |
525 | 600 | ], |
526 | 601 | 'desc': 'Range starting at the end of the first node and ending in the middle of the third node' |
527 | 602 | }, |
| 603 | + // Test 48 |
528 | 604 | { |
529 | 605 | 'node': root2, |
530 | 606 | 'input': new es.Range( 9, 29 ), |
— | — | @@ -534,6 +610,7 @@ |
535 | 611 | ], |
536 | 612 | 'desc': 'Range starting at the end of the first node and ending at the end of the third node' |
537 | 613 | }, |
| 614 | + // Test 49 |
538 | 615 | { |
539 | 616 | 'node': root2, |
540 | 617 | 'input': new es.Range( 9, 30 ), |
— | — | @@ -544,6 +621,7 @@ |
545 | 622 | ], |
546 | 623 | 'desc': 'Range starting at the end of the first node and ending past the end of the third node' |
547 | 624 | }, |
| 625 | + // Test 50 |
548 | 626 | { |
549 | 627 | 'node': root2, |
550 | 628 | 'input': new es.Range( 10, 21 ), |
— | — | @@ -553,6 +631,7 @@ |
554 | 632 | ], |
555 | 633 | 'desc': 'Range starting between the first and the second node and ending at the beginning of the third node' |
556 | 634 | }, |
| 635 | + // Test 51 |
557 | 636 | { |
558 | 637 | 'node': root2, |
559 | 638 | 'input': new es.Range( 10, 27 ), |
— | — | @@ -562,6 +641,7 @@ |
563 | 642 | ], |
564 | 643 | 'desc': 'Range starting between the first and the second node and ending in the middle of the third node' |
565 | 644 | }, |
| 645 | + // Test 56 |
566 | 646 | { |
567 | 647 | 'node': root2, |
568 | 648 | 'input': new es.Range( 10, 29 ), |
— | — | @@ -571,6 +651,7 @@ |
572 | 652 | ], |
573 | 653 | 'desc': 'Range starting between the first and the second node and ending at the end of the third node' |
574 | 654 | }, |
| 655 | + // Test 57 |
575 | 656 | { |
576 | 657 | 'node': root2, |
577 | 658 | 'input': new es.Range( 10, 30 ), |
— | — | @@ -580,6 +661,7 @@ |
581 | 662 | ], |
582 | 663 | 'desc': 'Range starting between the first and the second node and ending past the end of the third node' |
583 | 664 | }, |
| 665 | + // Test 58 |
584 | 666 | { |
585 | 667 | 'node': root2, |
586 | 668 | 'input': new es.Range( 11, 21 ), |
— | — | @@ -589,6 +671,7 @@ |
590 | 672 | ], |
591 | 673 | 'desc': 'Range starting at the beginning of the second node and ending at the beginning of the third node' |
592 | 674 | }, |
| 675 | + // Test 59 |
593 | 676 | { |
594 | 677 | 'node': root2, |
595 | 678 | 'input': new es.Range( 11, 27 ), |
— | — | @@ -598,6 +681,7 @@ |
599 | 682 | ], |
600 | 683 | 'desc': 'Range starting at the beginning of the second node and ending in the middle of the third node' |
601 | 684 | }, |
| 685 | + // Test 60 |
602 | 686 | { |
603 | 687 | 'node': root2, |
604 | 688 | 'input': new es.Range( 11, 29 ), |
— | — | @@ -607,6 +691,7 @@ |
608 | 692 | ], |
609 | 693 | 'desc': 'Range starting at the beginning of the second node and ending at the end of the third node' |
610 | 694 | }, |
| 695 | + // Test 61 |
611 | 696 | { |
612 | 697 | 'node': root2, |
613 | 698 | 'input': new es.Range( 11, 30 ), |
— | — | @@ -616,6 +701,7 @@ |
617 | 702 | ], |
618 | 703 | 'desc': 'Range starting at the beginning of the second node and ending past the end of the third node' |
619 | 704 | }, |
| 705 | + // Test 62 |
620 | 706 | { |
621 | 707 | 'node': root2, |
622 | 708 | 'input': new es.Range( 14, 21 ), |
— | — | @@ -625,6 +711,7 @@ |
626 | 712 | ], |
627 | 713 | 'desc': 'Range starting in the middle of the second node and ending at the beginning of the third node' |
628 | 714 | }, |
| 715 | + // Test 63 |
629 | 716 | { |
630 | 717 | 'node': root2, |
631 | 718 | 'input': new es.Range( 14, 27 ), |
— | — | @@ -634,6 +721,7 @@ |
635 | 722 | ], |
636 | 723 | 'desc': 'Range starting in the middle of the second node and ending in the middle of the third node' |
637 | 724 | }, |
| 725 | + // Test 64 |
638 | 726 | { |
639 | 727 | 'node': root2, |
640 | 728 | 'input': new es.Range( 14, 29 ), |
— | — | @@ -643,6 +731,7 @@ |
644 | 732 | ], |
645 | 733 | 'desc': 'Range starting in the middle of the second node and ending at the end of the third node' |
646 | 734 | }, |
| 735 | + // Test 65 |
647 | 736 | { |
648 | 737 | 'node': root2, |
649 | 738 | 'input': new es.Range( 14, 30 ), |
— | — | @@ -652,6 +741,7 @@ |
653 | 742 | ], |
654 | 743 | 'desc': 'Range starting in the middle of the second node and ending past the end of the third node' |
655 | 744 | }, |
| 745 | + // Test 66 |
656 | 746 | { |
657 | 747 | 'node': root2, |
658 | 748 | 'input': new es.Range( 19, 21 ), |
— | — | @@ -661,6 +751,7 @@ |
662 | 752 | ], |
663 | 753 | 'desc': 'Range starting at the end of the second node and ending at the beginning of the third node' |
664 | 754 | }, |
| 755 | + // Test 67 |
665 | 756 | { |
666 | 757 | 'node': root2, |
667 | 758 | 'input': new es.Range( 19, 27 ), |
— | — | @@ -670,6 +761,7 @@ |
671 | 762 | ], |
672 | 763 | 'desc': 'Range starting at the end of the second node and ending in the middle of the third node' |
673 | 764 | }, |
| 765 | + // Test 68 |
674 | 766 | { |
675 | 767 | 'node': root2, |
676 | 768 | 'input': new es.Range( 19, 29 ), |
— | — | @@ -679,6 +771,7 @@ |
680 | 772 | ], |
681 | 773 | 'desc': 'Range starting at the end of the second node and ending at the end of the third node' |
682 | 774 | }, |
| 775 | + // Test 69 |
683 | 776 | { |
684 | 777 | 'node': root2, |
685 | 778 | 'input': new es.Range( 19, 30 ), |
— | — | @@ -689,6 +782,8 @@ |
690 | 783 | 'desc': 'Range starting at the end of the second node and ending past the end of the third node' |
691 | 784 | }, |
692 | 785 | // Tests for childless nodes |
| 786 | + |
| 787 | + // Test 70 |
693 | 788 | { |
694 | 789 | 'node': g, |
695 | 790 | 'input': new es.Range( 1, 3 ), |
— | — | @@ -697,6 +792,7 @@ |
698 | 793 | ], |
699 | 794 | 'desc': 'Childless node given, range not out of bounds' |
700 | 795 | }, |
| 796 | + // Test 72 |
701 | 797 | { |
702 | 798 | 'node': g, |
703 | 799 | 'input': new es.Range( 0, 8 ), |
— | — | @@ -706,24 +802,29 @@ |
707 | 803 | 'desc': 'Childless node given, range covers entire node' |
708 | 804 | }, |
709 | 805 | // Tests for out-of-bounds cases |
| 806 | + |
| 807 | + // Test 73 |
710 | 808 | { |
711 | 809 | 'node': g, |
712 | 810 | 'input': new es.Range( -1, 3 ), |
713 | 811 | 'exception': /^The start offset of the range is negative$/, |
714 | 812 | 'desc': 'Childless node given, range start out of bounds' |
715 | 813 | }, |
| 814 | + // Test 74 |
716 | 815 | { |
717 | 816 | 'node': g, |
718 | 817 | 'input': new es.Range( 1, 9 ), |
719 | 818 | 'exception': /^The end offset of the range is past the end of the node$/, |
720 | 819 | 'desc': 'Childless node given, range end out of bounds' |
721 | 820 | }, |
| 821 | + // Test 75 |
722 | 822 | { |
723 | 823 | 'node': root2, |
724 | 824 | 'input': new es.Range( 31, 35 ), |
725 | 825 | 'exception': /^The start offset of the range is past the end of the node$/, |
726 | 826 | 'desc': 'Node with children given, range start out of bounds' |
727 | 827 | }, |
| 828 | + // Test 76 |
728 | 829 | { |
729 | 830 | 'node': root2, |
730 | 831 | 'input': new es.Range( 30, 35 ), |
— | — | @@ -731,6 +832,8 @@ |
732 | 833 | 'desc': 'Node with children given, range end out of bounds' |
733 | 834 | }, |
734 | 835 | // Tests for recursion cases |
| 836 | + |
| 837 | + // Test 77 |
735 | 838 | { |
736 | 839 | 'node': big, |
737 | 840 | 'input': new es.Range( 2, 10 ), |
— | — | @@ -740,16 +843,18 @@ |
741 | 844 | ], |
742 | 845 | 'desc': 'Select from before the b to after the d' |
743 | 846 | }, |
| 847 | + // Test 78 |
744 | 848 | { |
745 | 849 | 'node': big, |
746 | | - 'input': new es.Range( 3, 27 ), |
| 850 | + 'input': new es.Range( 3, 29 ), |
747 | 851 | 'output': [ |
748 | | - { 'node': big.children[0], 'range': new es.Range( 2, 3 ) }, |
| 852 | + { 'node': big.children[0], 'range': new es.Range( 2, 8 ) }, |
749 | 853 | { 'node': big.children[1] }, |
750 | | - { 'node': big.children[2], 'range': new es.Range( 0, 1 ) } |
| 854 | + { 'node': big.children[2], 'range': new es.Range( 0, 8 ) } |
751 | 855 | ], |
752 | 856 | 'desc': 'Select from before the c to after the h' |
753 | 857 | }, |
| 858 | + // Test 79 |
754 | 859 | { |
755 | 860 | 'node': big, |
756 | 861 | 'input': new es.Range( 9, 17 ), |
— | — | @@ -759,6 +864,7 @@ |
760 | 865 | ], |
761 | 866 | 'desc': 'Select from before the d to after the f, with recursion' |
762 | 867 | }, |
| 868 | + // Test 80 |
763 | 869 | { |
764 | 870 | 'node': big, |
765 | 871 | 'input': new es.Range( 9, 17 ), |
— | — | @@ -769,18 +875,53 @@ |
770 | 876 | 'desc': 'Select from before the d to after the f, without recursion' |
771 | 877 | } |
772 | 878 | ]; |
773 | | - |
| 879 | + |
| 880 | + function compare( a, b ) { |
| 881 | + if ( $.isArray( a ) && $.isArray( b ) && a.length === b.length ) { |
| 882 | + for ( var i = 0; i < a.length; i++ ) { |
| 883 | + if ( |
| 884 | + a[i].node !== b[i].node || |
| 885 | + ( |
| 886 | + ( typeof a[i].range !== typeof b[i].range ) || |
| 887 | + ( |
| 888 | + a[i].range !== undefined && |
| 889 | + ( |
| 890 | + a[i].range.start !== b[i].range.start || |
| 891 | + a[i].range.end !== b[i].range.end |
| 892 | + ) |
| 893 | + ) |
| 894 | + ) |
| 895 | + ) { |
| 896 | + return false; |
| 897 | + } |
| 898 | + } |
| 899 | + } |
| 900 | + return true; |
| 901 | + } |
| 902 | + function select( input, shallow ) { |
| 903 | + return function() { |
| 904 | + selectNodesTests[i].node.selectNodes( input, shallow ); |
| 905 | + }; |
| 906 | + } |
| 907 | + |
774 | 908 | for ( var i = 0; i < selectNodesTests.length; i++ ) { |
775 | 909 | if ( 'output' in selectNodesTests[i] ) { |
776 | | - deepEqual( |
777 | | - selectNodesTests[i].node.selectNodes( selectNodesTests[i].input, selectNodesTests[i].shallow ), |
778 | | - selectNodesTests[i].output, |
779 | | - selectNodesTests[i].desc |
| 910 | + var result = selectNodesTests[i].node.selectNodes( |
| 911 | + selectNodesTests[i].input, selectNodesTests[i].shallow |
| 912 | + ); |
| 913 | + ok( |
| 914 | + compare( result, selectNodesTests[i].output ), |
| 915 | + selectNodesTests[i].desc + |
| 916 | + ' (from ' + selectNodesTests[i].input.start + |
| 917 | + ' to ' + selectNodesTests[i].input.end + ')' |
780 | 918 | ); |
781 | 919 | } else if ( 'exception' in selectNodesTests[i] ) { |
782 | 920 | raises( |
783 | 921 | function() { |
784 | | - selectNodesTests[i].node.selectNodes( selectNodesTests[i].input, selectNodesTests[i].shallow ); |
| 922 | + selectNodesTests[i].node.selectNodes( |
| 923 | + selectNodesTests[i].input, |
| 924 | + selectNodesTests[i].shallow |
| 925 | + ); |
785 | 926 | }, |
786 | 927 | selectNodesTests[i].exception, |
787 | 928 | selectNodesTests[i].desc |
Index: trunk/extensions/VisualEditor/tests/es/es.testData.js |
— | — | @@ -67,27 +67,42 @@ |
68 | 68 | 'attributes': { |
69 | 69 | 'styles': ['bullet'] |
70 | 70 | }, |
71 | | - 'content': { |
72 | | - 'text': 'e' |
73 | | - } |
| 71 | + 'children': [ |
| 72 | + { |
| 73 | + 'type': 'paragraph', |
| 74 | + 'content': { |
| 75 | + 'text': 'e' |
| 76 | + } |
| 77 | + } |
| 78 | + ] |
74 | 79 | }, |
75 | 80 | { |
76 | 81 | 'type': 'listItem', |
77 | 82 | 'attributes': { |
78 | 83 | 'styles': ['bullet', 'bullet'] |
79 | 84 | }, |
80 | | - 'content': { |
81 | | - 'text': 'f' |
82 | | - } |
| 85 | + 'children': [ |
| 86 | + { |
| 87 | + 'type': 'paragraph', |
| 88 | + 'content': { |
| 89 | + 'text': 'f' |
| 90 | + } |
| 91 | + } |
| 92 | + ] |
83 | 93 | }, |
84 | 94 | { |
85 | 95 | 'type': 'listItem', |
86 | 96 | 'attributes': { |
87 | 97 | 'styles': ['number'] |
88 | 98 | }, |
89 | | - 'content': { |
90 | | - 'text': 'g' |
91 | | - } |
| 99 | + 'children': [ |
| 100 | + { |
| 101 | + 'type': 'paragraph', |
| 102 | + 'content': { |
| 103 | + 'text': 'g' |
| 104 | + } |
| 105 | + } |
| 106 | + ] |
92 | 107 | } |
93 | 108 | ] |
94 | 109 | } |
— | — | @@ -150,35 +165,47 @@ |
151 | 166 | { 'type': 'list' }, |
152 | 167 | // 12 - Beginning of bullet list item |
153 | 168 | { 'type': 'listItem', 'attributes': { 'styles': ['bullet'] } }, |
154 | | - // 13 - Plain content |
| 169 | + // 13 - Beginning of paragraph |
| 170 | + { 'type': 'paragraph' }, |
| 171 | + // 14 - Plain content |
155 | 172 | 'e', |
156 | | - // 14 - End of item |
| 173 | + // 15 - End of paragraph |
| 174 | + { 'type': '/paragraph' }, |
| 175 | + // 16 - End of item |
157 | 176 | { 'type': '/listItem' }, |
158 | | - // 15 - Beginning of nested bullet list item |
| 177 | + // 17 - Beginning of nested bullet list item |
159 | 178 | { 'type': 'listItem', 'attributes': { 'styles': ['bullet', 'bullet'] } }, |
160 | | - // 16 - Plain content |
| 179 | + // 18 - Beginning of paragraph |
| 180 | + { 'type': 'paragraph' }, |
| 181 | + // 19 - Plain content |
161 | 182 | 'f', |
162 | | - // 17 - End of item |
| 183 | + // 20 - End of paragraph |
| 184 | + { 'type': '/paragraph' }, |
| 185 | + // 21 - End of item |
163 | 186 | { 'type': '/listItem' }, |
164 | | - // 18 - Beginning of numbered list item |
| 187 | + // 22 - Beginning of numbered list item |
165 | 188 | { 'type': 'listItem', 'attributes': { 'styles': ['number'] } }, |
166 | | - // 19 - Plain content |
| 189 | + // 23 - Beginning of paragraph |
| 190 | + { 'type': 'paragraph' }, |
| 191 | + // 24 - Plain content |
167 | 192 | 'g', |
168 | | - // 20 - End of item |
| 193 | + // 25 - End of paragraph |
| 194 | + { 'type': '/paragraph' }, |
| 195 | + // 26 - End of item |
169 | 196 | { 'type': '/listItem' }, |
170 | | - // 21 - End of list |
| 197 | + // 27 - End of list |
171 | 198 | { 'type': '/list' }, |
172 | | - // 22 - End of cell |
| 199 | + // 28 - End of cell |
173 | 200 | { 'type': '/tableCell' }, |
174 | | - // 23 - End of row |
| 201 | + // 29 - End of row |
175 | 202 | { 'type': '/tableRow' }, |
176 | | - // 24 - End of table |
| 203 | + // 30 - End of table |
177 | 204 | { 'type': '/table' }, |
178 | | - // 25 - Beginning of paragraph |
| 205 | + // 31 - Beginning of paragraph |
179 | 206 | { 'type': 'paragraph' }, |
180 | | - // 26 - Plain content |
| 207 | + // 32 - Plain content |
181 | 208 | 'h', |
182 | | - // 27 - End of paragraph |
| 209 | + // 33 - End of paragraph |
183 | 210 | { 'type': '/paragraph' } |
184 | 211 | ]; |
185 | 212 | |
— | — | @@ -195,12 +222,18 @@ |
196 | 223 | new es.TableCellModel( esTest.data[7], [ |
197 | 224 | new es.ParagraphModel( esTest.data[8], 1 ), |
198 | 225 | new es.ListModel( esTest.data[11], [ |
199 | | - new es.ListItemModel( esTest.data[12], 1 ), |
200 | | - new es.ListItemModel( esTest.data[15], 1 ), |
201 | | - new es.ListItemModel( esTest.data[18], 1 ) |
| 226 | + new es.ListItemModel( esTest.data[12], [ |
| 227 | + new es.ParagraphModel( esTest.data[13], 1 ) |
| 228 | + ] ), |
| 229 | + new es.ListItemModel( esTest.data[17], [ |
| 230 | + new es.ParagraphModel( esTest.data[18], 1 ) |
| 231 | + ] ), |
| 232 | + new es.ListItemModel( esTest.data[22], [ |
| 233 | + new es.ParagraphModel( esTest.data[23], 1 ) |
| 234 | + ] ) |
202 | 235 | ] ) |
203 | 236 | ] ) |
204 | 237 | ] ) |
205 | 238 | ] ), |
206 | | - new es.ParagraphModel( esTest.data[25], 1 ) |
| 239 | + new es.ParagraphModel( esTest.data[31], 1 ) |
207 | 240 | ]; |
Index: trunk/extensions/VisualEditor/tests/es/es.DocumentModel.test.js |
— | — | @@ -67,8 +67,8 @@ |
68 | 68 | ); |
69 | 69 | // Test 4 |
70 | 70 | equal( |
71 | | - documentModel.getRelativeContentOffset( 27, 1 ), |
72 | | - 27, |
| 71 | + documentModel.getRelativeContentOffset( 32, 1 ), |
| 72 | + 32, |
73 | 73 | 'getRelativeContentOffset treats the end a document as a non-content offset' |
74 | 74 | ); |
75 | 75 | // Test 5 |
— | — | @@ -79,8 +79,8 @@ |
80 | 80 | ); |
81 | 81 | // Test 6 |
82 | 82 | equal( |
83 | | - documentModel.getRelativeContentOffset( 26, -1 ), |
84 | | - 20, |
| 83 | + documentModel.getRelativeContentOffset( 32, -1 ), |
| 84 | + 25, |
85 | 85 | 'getRelativeContentOffset advances backwards between elements' |
86 | 86 | ); |
87 | 87 | } ); |
— | — | @@ -221,7 +221,7 @@ |
222 | 222 | documentModel.prepareElementAttributeChange( 0, 'set', 'test', 1234 ).getOperations(), |
223 | 223 | [ |
224 | 224 | { 'type': 'attribute', 'method': 'set', 'key': 'test', 'value': 1234 }, |
225 | | - { 'type': 'retain', 'length': 28 } |
| 225 | + { 'type': 'retain', 'length': 34 } |
226 | 226 | ], |
227 | 227 | 'prepareElementAttributeChange retains data after attribute change for first element' |
228 | 228 | ); |
— | — | @@ -232,7 +232,7 @@ |
233 | 233 | [ |
234 | 234 | { 'type': 'retain', 'length': 5 }, |
235 | 235 | { 'type': 'attribute', 'method': 'set', 'key': 'test', 'value': 1234 }, |
236 | | - { 'type': 'retain', 'length': 23 } |
| 236 | + { 'type': 'retain', 'length': 29 } |
237 | 237 | ], |
238 | 238 | 'prepareElementAttributeChange retains data before and after attribute change' |
239 | 239 | ); |
— | — | @@ -295,7 +295,7 @@ |
296 | 296 | 'bias': 'stop', |
297 | 297 | 'annotation': { 'type': 'textStyle/bold', 'hash': '#textStyle/bold' } |
298 | 298 | }, |
299 | | - { 'type': 'retain', 'length': 24 } |
| 299 | + { 'type': 'retain', 'length': 30 } |
300 | 300 | ], |
301 | 301 | 'prepareContentAnnotation skips over content that is already set or cleared' |
302 | 302 | ); |
— | — | @@ -317,34 +317,36 @@ |
318 | 318 | ['c', { 'type': 'textStyle/italic', 'hash': '#textStyle/italic' }] |
319 | 319 | ] |
320 | 320 | }, |
321 | | - { 'type': 'retain', 'length': 24 } |
| 321 | + { 'type': 'retain', 'length': 30 } |
322 | 322 | ], |
323 | 323 | 'prepareRemoval includes the content being removed' |
324 | 324 | ); |
325 | 325 | |
326 | 326 | // Test 2 |
327 | 327 | deepEqual( |
328 | | - documentModel.prepareRemoval( new es.Range( 15, 18 ) ).getOperations(), |
| 328 | + documentModel.prepareRemoval( new es.Range( 17, 22 ) ).getOperations(), |
329 | 329 | [ |
330 | | - { 'type': 'retain', 'length': 15 }, |
| 330 | + { 'type': 'retain', 'length': 17 }, |
331 | 331 | { |
332 | 332 | 'type': 'remove', |
333 | 333 | 'data': [ |
334 | 334 | { 'type': 'listItem', 'attributes': { 'styles': ['bullet', 'bullet'] } }, |
| 335 | + { 'type': 'paragraph' }, |
335 | 336 | 'f', |
| 337 | + { 'type': '/paragraph' }, |
336 | 338 | { 'type': '/listItem' } |
337 | 339 | ] |
338 | 340 | }, |
339 | | - { 'type': 'retain', 'length': 10 } |
| 341 | + { 'type': 'retain', 'length': 12 } |
340 | 342 | ], |
341 | 343 | 'prepareRemoval removes entire elements' |
342 | 344 | ); |
343 | 345 | |
344 | 346 | // Test 3 |
345 | 347 | deepEqual( |
346 | | - documentModel.prepareRemoval( new es.Range( 17, 19 ) ).getOperations(), |
| 348 | + documentModel.prepareRemoval( new es.Range( 21, 23 ) ).getOperations(), |
347 | 349 | [ |
348 | | - { 'type': 'retain', 'length': 17 }, |
| 350 | + { 'type': 'retain', 'length': 21 }, |
349 | 351 | { |
350 | 352 | 'type': 'remove', |
351 | 353 | 'data': [ |
— | — | @@ -352,7 +354,7 @@ |
353 | 355 | { 'type': 'listItem', 'attributes': { 'styles': ['number'] } } |
354 | 356 | ] |
355 | 357 | }, |
356 | | - { 'type': 'retain', 'length': 9 } |
| 358 | + { 'type': 'retain', 'length': 11 } |
357 | 359 | ], |
358 | 360 | 'prepareRemoval merges two list items' |
359 | 361 | ); |
— | — | @@ -368,7 +370,7 @@ |
369 | 371 | ['c', { 'type': 'textStyle/italic', 'hash': '#textStyle/italic' }] |
370 | 372 | ] |
371 | 373 | }, |
372 | | - { 'type': 'retain', 'length': 24 } |
| 374 | + { 'type': 'retain', 'length': 30 } |
373 | 375 | ], |
374 | 376 | 'prepareRemoval works across structural nodes' |
375 | 377 | ); |
— | — | @@ -383,7 +385,7 @@ |
384 | 386 | [ |
385 | 387 | { 'type': 'retain', 'length': 1 }, |
386 | 388 | { 'type': 'insert', 'data': ['d', 'e', 'f'] }, |
387 | | - { 'type': 'retain', 'length': 27 } |
| 389 | + { 'type': 'retain', 'length': 33 } |
388 | 390 | ], |
389 | 391 | 'prepareInsertion retains data up to the offset and includes the content being inserted' |
390 | 392 | ); |
— | — | @@ -399,7 +401,7 @@ |
400 | 402 | 'type': 'insert', |
401 | 403 | 'data': [{ 'type': 'paragraph' }, 'd', 'e', 'f', { 'type': '/paragraph' }] |
402 | 404 | }, |
403 | | - { 'type': 'retain', 'length': 23 } |
| 405 | + { 'type': 'retain', 'length': 29 } |
404 | 406 | ], |
405 | 407 | 'prepareInsertion inserts a paragraph between two structural elements' |
406 | 408 | ); |
— | — | @@ -413,7 +415,7 @@ |
414 | 416 | 'type': 'insert', |
415 | 417 | 'data': [{ 'type': 'paragraph' }, 'd', 'e', 'f', { 'type': '/paragraph' }] |
416 | 418 | }, |
417 | | - { 'type': 'retain', 'length': 23 } |
| 419 | + { 'type': 'retain', 'length': 29 } |
418 | 420 | ], |
419 | 421 | 'prepareInsertion wraps unstructured content inserted between elements in a paragraph' |
420 | 422 | ); |
— | — | @@ -429,7 +431,7 @@ |
430 | 432 | 'type': 'insert', |
431 | 433 | 'data': [{ 'type': 'paragraph' }, 'd', 'e', 'f', { 'type': '/paragraph' }] |
432 | 434 | }, |
433 | | - { 'type': 'retain', 'length': 23 } |
| 435 | + { 'type': 'retain', 'length': 29 } |
434 | 436 | ], |
435 | 437 | 'prepareInsertion completes opening elements in inserted content' |
436 | 438 | ); |
— | — | @@ -450,7 +452,7 @@ |
451 | 453 | { 'type': 'paragraph' } |
452 | 454 | ] |
453 | 455 | }, |
454 | | - { 'type': 'retain', 'length': 26 } |
| 456 | + { 'type': 'retain', 'length': 32 } |
455 | 457 | ], |
456 | 458 | 'prepareInsertion splits up paragraph when inserting a table in the middle' |
457 | 459 | ); |
— | — | @@ -475,7 +477,7 @@ |
476 | 478 | 'r' |
477 | 479 | ] |
478 | 480 | }, |
479 | | - { 'type': 'retain', 'length': 26 } |
| 481 | + { 'type': 'retain', 'length': 32 } |
480 | 482 | ], |
481 | 483 | 'prepareInsertion splits paragraph when inserting a paragraph closing and opening inside it' |
482 | 484 | ); |
— | — | @@ -490,7 +492,7 @@ |
491 | 493 | 'type': 'insert', |
492 | 494 | 'data': [ { 'type': 'paragraph' }, 'f', 'o', 'o', { 'type': '/paragraph' } ] |
493 | 495 | }, |
494 | | - { 'type': 'retain', 'length': 28 } |
| 496 | + { 'type': 'retain', 'length': 34 } |
495 | 497 | ], |
496 | 498 | 'prepareInsertion inserts at the beginning, then retains up to the end' |
497 | 499 | ); |
— | — | @@ -498,10 +500,10 @@ |
499 | 501 | // Test 8 |
500 | 502 | deepEqual( |
501 | 503 | documentModel.prepareInsertion( |
502 | | - 28, [ { 'type': 'paragraph' }, 'f', 'o', 'o', { 'type': '/paragraph' } ] |
| 504 | + 34, [ { 'type': 'paragraph' }, 'f', 'o', 'o', { 'type': '/paragraph' } ] |
503 | 505 | ).getOperations(), |
504 | 506 | [ |
505 | | - { 'type': 'retain', 'length': 28 }, |
| 507 | + { 'type': 'retain', 'length': 34 }, |
506 | 508 | { |
507 | 509 | 'type': 'insert', |
508 | 510 | 'data': [ { 'type': 'paragraph' }, 'f', 'o', 'o', { 'type': '/paragraph' } ] |
— | — | @@ -526,11 +528,11 @@ |
527 | 529 | raises( |
528 | 530 | function() { |
529 | 531 | documentModel.prepareInsertion( |
530 | | - 29, |
| 532 | + 35, |
531 | 533 | [ { 'type': 'paragraph' }, 'f', 'o', 'o', { 'type': '/paragraph' } ] |
532 | 534 | ); |
533 | 535 | }, |
534 | | - /^Offset 29 out of bounds/, |
| 536 | + /^Offset 35 out of bounds/, |
535 | 537 | 'prepareInsertion throws exception for offset past the end' |
536 | 538 | ); |
537 | 539 | |