@@ -29,6 +29,9 @@ import {
2929 jsonRteClassAndIdAttrs ,
3030 styleObj ,
3131 unorderListJson1 ,
32+ nestedOrderedListJson ,
33+ nestedOrderedListSiblingStructureJson ,
34+ nestedUnorderedListSiblingStructureJson ,
3235 unorderListJson2 ,
3336 orderListJson2 ,
3437 testJsonRte ,
@@ -566,9 +569,63 @@ describe('Node parse list content', () => {
566569
567570 jsonToHTML ( { entry, paths} )
568571
569- expect ( entry . supercharged_rte ) . toEqual ( '<ul><li>One</li>< ul><li>nested one</li><li>nested two</li></ul><li>Two</li></ul>' )
572+ expect ( entry . supercharged_rte ) . toEqual ( '<ul><li>One<ul><li>nested one</li><li>nested two</li></ul></li ><li>Two</li></ul>' )
570573 done ( )
571574 } )
575+ it ( 'should return valid HTML5 nested list when JSON RTE has sibling-structure' , done => {
576+ const entry = {
577+ uid : 'entry_uid_19' ,
578+ supercharged_rte : {
579+ ...nestedOrderedListJson
580+ } ,
581+ _embedded_items : { }
582+ }
583+ const paths = [ 'supercharged_rte' ]
584+
585+ jsonToHTML ( { entry, paths} )
586+
587+ expect ( entry . supercharged_rte ) . toEqual ( `<ol><li>Item 1</li><li>Item 2<ol><li>Nested Item 1</li><li>Nested Item 2</li></ol></li></ol>` )
588+ done ( )
589+ } )
590+
591+ it ( 'should return valid HTML5 for ordered list when JSON RTE has nested ol as SIBLING of li' , done => {
592+ const entry = {
593+ uid : 'entry_uid_19' ,
594+ supercharged_rte : {
595+ ...nestedOrderedListSiblingStructureJson
596+ } ,
597+ _embedded_items : { }
598+ }
599+ const paths = [ 'supercharged_rte' ]
600+
601+ jsonToHTML ( { entry, paths } )
602+
603+ // Valid HTML5: nested <ol> must be inside the preceding <li>, not a direct child of parent <ol>
604+ expect ( entry . supercharged_rte ) . toEqual (
605+ '<ol><li>Item 1</li><li>Item 2<ol><li>Nested Item 1</li><li>Nested Item 2</li></ol></li></ol>'
606+ )
607+ done ( )
608+ } )
609+
610+ it ( 'should return valid HTML5 for unordered list when JSON RTE has nested ul as SIBLING of li' , done => {
611+ const entry = {
612+ uid : 'entry_uid_19' ,
613+ supercharged_rte : {
614+ ...nestedUnorderedListSiblingStructureJson
615+ } ,
616+ _embedded_items : { }
617+ }
618+ const paths = [ 'supercharged_rte' ]
619+
620+ jsonToHTML ( { entry, paths } )
621+
622+ // Valid HTML5: nested <ul> must be inside the preceding <li>, not a direct child of parent <ul>
623+ expect ( entry . supercharged_rte ) . toEqual (
624+ '<ul><li>Item A</li><li>Item B<ul><li>Nested A</li><li>Nested B</li></ul></li></ul>'
625+ )
626+ done ( )
627+ } )
628+
572629 it ( 'Should return unorder list html content for updated json rte' , done => {
573630 const entry = {
574631 uid : 'entry_uid_19' ,
0 commit comments