@@ -274,6 +274,58 @@ test("#parse handles multiple headers in list item", assert => {
274274 assert . equal ( h2 . tagName , 'h2' ) ;
275275} ) ;
276276
277+ // https://github.com/bustle/mobiledoc-kit/issues/714
278+ test ( '#parse handles list items following a markup-section breakout' , ( assert ) => {
279+ let container = buildDOM ( `
280+ <ul><li>One</li><li><h2>Two</h2></li><li>Three</li><li>Four</li></ul>
281+ ` ) ;
282+
283+ let element = container . firstChild ;
284+ parser = new SectionParser ( builder ) ;
285+ let sections = parser . parse ( element ) ;
286+
287+ assert . equal ( sections . length , 3 , '3 sections' ) ;
288+
289+ assert . equal ( sections [ 0 ] . type , 'list-section' ) ;
290+ assert . equal ( sections [ 0 ] . items . length , 1 ) ;
291+ assert . equal ( sections [ 0 ] . items . objectAt ( 0 ) . text , 'One' ) ;
292+
293+ assert . equal ( sections [ 1 ] . type , 'markup-section' ) ;
294+ assert . equal ( sections [ 1 ] . tagName , 'h2' ) ;
295+ assert . equal ( sections [ 1 ] . text , 'Two' ) ;
296+
297+ assert . equal ( sections [ 2 ] . type , 'list-section' ) ;
298+ assert . equal ( sections [ 2 ] . items . length , 2 ) ;
299+ assert . equal ( sections [ 2 ] . items . objectAt ( 0 ) . text , 'Three' ) ;
300+ assert . equal ( sections [ 2 ] . items . objectAt ( 1 ) . text , 'Four' ) ;
301+ } ) ;
302+
303+ // https://github.com/bustle/mobiledoc-kit/issues/714
304+ test ( '#parse handles "invalid" non-li elems inside lists' , ( assert ) => {
305+ let container = buildDOM ( `
306+ <ul><li>One</li><h2>Two</h2><li>Three</li><li>Four</li></ul>
307+ ` ) ;
308+
309+ let element = container . firstChild ;
310+ parser = new SectionParser ( builder ) ;
311+ let sections = parser . parse ( element ) ;
312+
313+ assert . equal ( sections . length , 3 , '3 sections' ) ;
314+
315+ assert . equal ( sections [ 0 ] . type , 'list-section' ) ;
316+ assert . equal ( sections [ 0 ] . items . length , 1 ) ;
317+ assert . equal ( sections [ 0 ] . items . objectAt ( 0 ) . text , 'One' ) ;
318+
319+ assert . equal ( sections [ 1 ] . type , 'markup-section' ) ;
320+ assert . equal ( sections [ 1 ] . tagName , 'h2' ) ;
321+ assert . equal ( sections [ 1 ] . text , 'Two' ) ;
322+
323+ assert . equal ( sections [ 2 ] . type , 'list-section' ) ;
324+ assert . equal ( sections [ 2 ] . items . length , 2 ) ;
325+ assert . equal ( sections [ 2 ] . items . objectAt ( 0 ) . text , 'Three' ) ;
326+ assert . equal ( sections [ 2 ] . items . objectAt ( 1 ) . text , 'Four' ) ;
327+ } ) ;
328+
277329// see https://github.com/bustle/mobiledoc-kit/issues/656
278330test ( '#parse handles list following node handled by parserPlugin' , ( assert ) => {
279331 let container = buildDOM ( `
@@ -536,3 +588,4 @@ test('#parse handles card-creating element after plain text', (assert) => {
536588 assert . equal ( sections [ 1 ] . type , 'card-section' ) ;
537589 assert . equal ( sections [ 2 ] . text . trim ( ) , 'After' ) ;
538590} ) ;
591+
0 commit comments