@@ -357,123 +357,6 @@ test('#isBlank is true when there are no sections', (assert) => {
357357 assert . ok ( ! _post . isBlank ) ;
358358} ) ;
359359
360- // see https://github.com/bustlelabs/mobiledoc-kit/issues/134
361- test ( '#sectionsContainedBy when range covers two list items' , ( assert ) => {
362- const post = Helpers . postAbstract . build (
363- ( { post, markupSection, marker, listSection, listItem} ) => {
364- return post ( [
365- listSection ( 'ul' , [ listItem ( [ marker ( 'abc' ) ] ) , listItem ( ) ] ) ,
366- markupSection ( 'p' , [ marker ( '123' ) ] )
367- ] ) ;
368- } ) ;
369- const li1 = post . sections . head . items . head ,
370- li2 = post . sections . head . items . tail ;
371- const section = post . sections . tail ;
372- assert . equal ( li1 . text , 'abc' , 'precond - li1 text' ) ;
373- assert . equal ( li2 . text , '' , 'precond - li2 text' ) ;
374- assert . equal ( section . text , '123' , 'precond - section text' ) ;
375-
376- const range = Range . create ( li1 , 0 , li2 , li2 . length ) ;
377- const containedSections = post . sectionsContainedBy ( range ) ;
378- assert . equal ( containedSections . length , 0 , 'no sections are contained' ) ;
379- } ) ;
380-
381- test ( '#sectionsContainedBy when range contains no sections' , ( assert ) => {
382- const post = Helpers . postAbstract . build (
383- ( { post, markupSection, marker} ) => {
384- return post ( [
385- markupSection ( 'p' , [ marker ( 'abc' ) ] ) ,
386- markupSection ( 'p' , [ marker ( '123' ) ] )
387- ] ) ;
388- } ) ;
389- const s1 = post . sections . head ,
390- s2 = post . sections . tail ;
391- assert . equal ( s1 . text , 'abc' , 'precond - s1 text' ) ;
392- assert . equal ( s2 . text , '123' , 'precond - s2 text' ) ;
393-
394- const range = Range . create ( s1 , 0 , s2 , s2 . length ) ;
395- const containedSections = post . sectionsContainedBy ( range ) ;
396- assert . equal ( containedSections . length , 0 , 'no sections are contained' ) ;
397- } ) ;
398-
399- test ( '#sectionsContainedBy when range contains sections' , ( assert ) => {
400- const post = Helpers . postAbstract . build (
401- ( { post, markupSection, marker} ) => {
402- return post ( [
403- markupSection ( 'p' , [ marker ( 'abc' ) ] ) ,
404- markupSection ( 'p' , [ marker ( 'inner' ) ] ) ,
405- markupSection ( 'p' , [ marker ( '123' ) ] )
406- ] ) ;
407- } ) ;
408- const s1 = post . sections . head ,
409- sInner = post . sections . objectAt ( 1 ) ,
410- s2 = post . sections . tail ;
411- assert . equal ( s1 . text , 'abc' , 'precond - s1 text' ) ;
412- assert . equal ( sInner . text , 'inner' , 'precond - sInner text' ) ;
413- assert . equal ( s2 . text , '123' , 'precond - s2 text' ) ;
414-
415- const range = Range . create ( s1 , 0 , s2 , s2 . length ) ;
416- const containedSections = post . sectionsContainedBy ( range ) ;
417- assert . equal ( containedSections . length , 1 , '1 sections are contained' ) ;
418- assert . ok ( containedSections [ 0 ] === sInner , 'inner section is contained' ) ;
419- } ) ;
420-
421- test ( '#sectionsContainedBy when range contains non-markerable sections' , ( assert ) => {
422- const post = Helpers . postAbstract . build (
423- ( { post, markupSection, marker, cardSection, listSection, listItem} ) => {
424- return post ( [
425- markupSection ( 'p' , [ marker ( 'abc' ) ] ) ,
426- cardSection ( 'test-card' ) ,
427- listSection ( 'ul' , [ listItem ( [ marker ( 'li' ) ] ) ] ) ,
428- markupSection ( 'p' , [ marker ( '123' ) ] )
429- ] ) ;
430- } ) ;
431- const s1 = post . sections . head ,
432- card = post . sections . objectAt ( 1 ) ,
433- list = post . sections . objectAt ( 2 ) ,
434- s2 = post . sections . tail ;
435-
436- assert . equal ( s1 . text , 'abc' , 'precond - s1 text' ) ;
437- assert . equal ( s2 . text , '123' , 'precond - s2 text' ) ;
438- const range = Range . create ( s1 , 0 , s2 , s2 . length ) ;
439- const containedSections = post . sectionsContainedBy ( range ) ;
440- assert . equal ( containedSections . length , 2 , '2 sections are contained' ) ;
441- assert . ok ( containedSections . indexOf ( card ) !== - 1 , 'contains card' ) ;
442- assert . ok ( containedSections . indexOf ( list ) !== - 1 , 'contains list' ) ;
443- } ) ;
444-
445- test ( '#sectionsContainedBy when range starts/ends in list item' , ( assert ) => {
446- const post = Helpers . postAbstract . build (
447- ( { post, markupSection, marker, cardSection, listSection, listItem} ) => {
448- return post ( [
449- listSection ( 'ul' , [
450- listItem ( [ marker ( 'ul1 li1' ) ] ) ,
451- listItem ( [ marker ( 'ul1 li2' ) ] )
452- ] ) ,
453- markupSection ( 'p' , [ marker ( 'abc' ) ] ) ,
454- cardSection ( 'test-card' ) ,
455- listSection ( 'ul' , [
456- listItem ( [ marker ( 'ul2 li1' ) ] ) ,
457- listItem ( [ marker ( 'ul2 li2' ) ] )
458- ] )
459- ] ) ;
460- } ) ;
461- const li1 = post . sections . head . items . head ,
462- li2 = post . sections . tail . items . tail ,
463- s1 = post . sections . objectAt ( 1 ) ,
464- card = post . sections . objectAt ( 2 ) ;
465-
466- assert . equal ( li1 . text , 'ul1 li1' , 'precond - li1 text' ) ;
467- assert . equal ( li2 . text , 'ul2 li2' , 'precond - li2 text' ) ;
468- assert . equal ( s1 . text , 'abc' , 'precond - s1 text' ) ;
469-
470- const range = Range . create ( li1 , li1 . length , li2 , li2 . length ) ;
471- const containedSections = post . sectionsContainedBy ( range ) ;
472- assert . equal ( containedSections . length , 2 , '2 sections are contained' ) ;
473- assert . ok ( containedSections . indexOf ( card ) !== - 1 , 'contains card' ) ;
474- assert . ok ( containedSections . indexOf ( s1 ) !== - 1 , 'contains section' ) ;
475- } ) ;
476-
477360test ( '#trimTo creates a post from the given range' , ( assert ) => {
478361 let post = Helpers . postAbstract . build (
479362 ( { post, markupSection, marker} ) => {
0 commit comments