r100717 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100716‎ | r100717 | r100718 >
Date:17:37, 25 October 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Split tests by method
Modified paths:
  • /trunk/parsers/wikidom/tests/hype/es.DocumentModel.test.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/tests/hype/es.DocumentModel.test.js
@@ -201,16 +201,24 @@
202202 new es.ParagraphModel( data[25], 1 )
203203 ];
204204
205 -test( 'es.DocumentModel', 23, function() {
 205+test( 'es.DocumentModel.getData', 1, function() {
206206 var documentModel = es.DocumentModel.newFromPlainObject( obj );
207207
208208 // Test 1
209209 deepEqual( documentModel.getData(), data, 'Flattening plain objects results in correct data' );
 210+} );
210211
211 - // Test 2
 212+test( 'es.DocumentModel.slice', 1, function() {
 213+ var documentModel = es.DocumentModel.newFromPlainObject( obj );
 214+
 215+ // Test 1
212216 deepEqual( documentModel.slice( 0 ), tree, 'Nodes in the model tree contain correct lengths' );
 217+} );
 218+
 219+test( 'es.DocumentModel.getContent', 6, function() {
 220+ var documentModel = es.DocumentModel.newFromPlainObject( obj );
213221
214 - // Test 3
 222+ // Test 1
215223 deepEqual(
216224 documentModel[0].getContent( new es.Range( 1, 3 ) ),
217225 [
@@ -220,14 +228,14 @@
221229 'getContent can return an ending portion of the content'
222230 );
223231
224 - // Test 4
 232+ // Test 2
225233 deepEqual(
226234 documentModel[0].getContent( new es.Range( 0, 2 ) ),
227235 ['a', ['b', { 'type': 'bold', 'hash': '#bold' }]],
228236 'getContent can return a beginning portion of the content'
229237 );
230238
231 - // Test 5
 239+ // Test 3
232240 deepEqual(
233241 documentModel[0].getContent( new es.Range( 1, 2 ) ),
234242 [['b', { 'type': 'bold', 'hash': '#bold' }]],
@@ -237,47 +245,55 @@
238246 try {
239247 documentModel[0].getContent( new es.Range( -1, 3 ) );
240248 } catch ( negativeIndexError ) {
241 - // Test 6
 249+ // Test 4
242250 ok( true, 'getContent throws exceptions when given a range with start < 0' );
243251 }
244252
245253 try {
246254 documentModel[0].getContent( new es.Range( 0, 4 ) );
247255 } catch ( outOfRangeError ) {
248 - // Test 7
 256+ // Test 5
249257 ok( true, 'getContent throws exceptions when given a range with end > length' );
250258 }
251259
252 - // Test 8
 260+ // Test 6
253261 deepEqual( documentModel[2].getContent(), ['a'], 'Content can be extracted from nodes' );
 262+} );
 263+
 264+test( 'es.DocumentModel.getIndexOfAnnotation', 3, function() {
 265+ var documentModel = es.DocumentModel.newFromPlainObject( obj );
254266
255267 var bold = { 'type': 'bold', 'hash': '#bold' },
256268 italic = { 'type': 'italic', 'hash': '#italic' },
257269 nothing = { 'type': 'nothing', 'hash': '#nothing' },
258270 character = ['a', bold, italic];
259271
260 - // Test 9
 272+ // Test 1
261273 equal(
262274 es.DocumentModel.getIndexOfAnnotation( character, bold ),
263275 1,
264276 'getIndexOfAnnotation get the correct index'
265277 );
266278
267 - // Test 10
 279+ // Test 2
268280 equal(
269281 es.DocumentModel.getIndexOfAnnotation( character, italic ),
270282 2,
271283 'getIndexOfAnnotation get the correct index'
272284 );
273285
274 - // Test 11
 286+ // Test 3
275287 equal(
276288 es.DocumentModel.getIndexOfAnnotation( character, nothing ),
277289 -1,
278290 'getIndexOfAnnotation returns -1 if the annotation was not found'
279291 );
280 -
281 - // Test 12
 292+} );
 293+
 294+test( 'es.DocumentModel.prepareElementAttributeChange', 4, function() {
 295+ var documentModel = es.DocumentModel.newFromPlainObject( obj );
 296+
 297+ // Test 1
282298 deepEqual(
283299 documentModel.prepareElementAttributeChange( 0, 'set', 'test', 1234 ),
284300 [
@@ -287,7 +303,7 @@
288304 'prepareElementAttributeChange retains data after attribute change for first element'
289305 );
290306
291 - // Test 13
 307+ // Test 2
292308 deepEqual(
293309 documentModel.prepareElementAttributeChange( 5, 'set', 'test', 1234 ),
294310 [
@@ -301,7 +317,7 @@
302318 try {
303319 documentModel.prepareElementAttributeChange( 1, 'set', 'test', 1234 );
304320 } catch ( invalidOffsetError ) {
305 - // Test 14
 321+ // Test 3
306322 ok(
307323 true,
308324 'prepareElementAttributeChange throws an exception when offset is not an element'
@@ -311,14 +327,18 @@
312328 try {
313329 documentModel.prepareElementAttributeChange( 4, 'set', 'test', 1234 );
314330 } catch ( closingElementError ) {
315 - // Test 15
 331+ // Test 4
316332 ok(
317333 true,
318334 'prepareElementAttributeChange throws an exception when offset is a closing element'
319335 );
320336 }
321 -
322 - // Test 16
 337+} );
 338+
 339+test( 'es.DocumentModel.prepareContentAnnotation', 1, function() {
 340+ var documentModel = es.DocumentModel.newFromPlainObject( obj );
 341+
 342+ // Test 1
323343 deepEqual(
324344 documentModel.prepareContentAnnotation( new es.Range( 1, 4 ), 'set', { 'type': 'bold' } ),
325345 [
@@ -354,8 +374,12 @@
355375 ],
356376 'prepareContentAnnotation skips over content that is already set or cleared'
357377 );
358 -
359 - // Test 17
 378+} );
 379+
 380+test( 'es.DocumentModel.prepareRemoval', 3, function() {
 381+ var documentModel = es.DocumentModel.newFromPlainObject( obj );
 382+
 383+ // Test 1
360384 deepEqual(
361385 documentModel.prepareRemoval( new es.Range( 1, 4 ) ),
362386 [
@@ -373,7 +397,7 @@
374398 'prepareRemoval includes the content being removed'
375399 );
376400
377 - // Test 18
 401+ // Test 2
378402 deepEqual(
379403 documentModel.prepareRemoval( new es.Range( 15, 18 ) ),
380404 [
@@ -391,7 +415,7 @@
392416 'prepareRemoval removes entire elements'
393417 );
394418
395 - // Test 19
 419+ // Test 3
396420 deepEqual(
397421 documentModel.prepareRemoval( new es.Range( 17, 19 ) ),
398422 [
@@ -407,8 +431,12 @@
408432 ],
409433 'prepareRemoval merges two list items'
410434 );
411 -
412 - // Test 20
 435+} );
 436+
 437+test( 'es.DocumentModel.prepareInsertion', 4, function() {
 438+ var documentModel = es.DocumentModel.newFromPlainObject( obj );
 439+
 440+ // Test 1
413441 deepEqual(
414442 documentModel.prepareInsertion( 1, ['d', 'e', 'f'] ),
415443 [
@@ -419,7 +447,7 @@
420448 'prepareInsertion retains data up to the offset and includes the content being inserted'
421449 );
422450
423 - // Test 21
 451+ // Test 2
424452 deepEqual(
425453 documentModel.prepareInsertion(
426454 5,
@@ -436,7 +464,7 @@
437465 'prepareInsertion inserts a paragraph between two structural elements'
438466 );
439467
440 - // Test 22
 468+ // Test 3
441469 deepEqual(
442470 documentModel.prepareInsertion(
443471 5,
@@ -453,7 +481,7 @@
454482 'prepareInsertion wraps unstructured content inserted between elements in a paragraph'
455483 );
456484
457 - // Test 23
 485+ // Test 4
458486 deepEqual(
459487 documentModel.prepareInsertion(
460488 5,

Status & tagging log