@@ -59,5 +59,40 @@ describe( 'ContainerElement', () => {
5959 it ( 'should return null if element is not empty' , ( ) => {
6060 expect ( parse ( '<container:p>foo</container:p>' ) . getFillerOffset ( ) ) . to . be . null ;
6161 } ) ;
62+
63+ // Block filler is required after the `<br>` element if the element is the last child in the container. See #1422.
64+ describe ( 'for <br> elements in container' , ( ) => {
65+ it ( 'returns null because container does not need the block filler' , ( ) => {
66+ expect ( parse ( '<container:p>Foo.</container:p>' ) . getFillerOffset ( ) ) . to . equals ( null ) ;
67+ } ) ;
68+
69+ it ( 'returns offset of the last child which is the <br> element (1)' , ( ) => {
70+ expect ( parse ( '<container:p><empty:br></empty:br></container:p>' ) . getFillerOffset ( ) ) . to . equals ( 1 ) ;
71+ } ) ;
72+
73+ it ( 'returns offset of the last child which is the <br> element (2)' , ( ) => {
74+ expect ( parse ( '<container:p>Foo.<empty:br></empty:br></container:p>' ) . getFillerOffset ( ) ) . to . equals ( 2 ) ;
75+ } ) ;
76+
77+ it ( 'always returns the last <br> element in the container' , ( ) => {
78+ expect ( parse ( '<container:p>Foo.<empty:br></empty:br><empty:br></empty:br></container:p>' ) . getFillerOffset ( ) )
79+ . to . equals ( 3 ) ;
80+ } ) ;
81+
82+ it ( 'works fine with non-empty container with multi <br> elements' , ( ) => {
83+ expect ( parse ( '<container:p>Foo.<empty:br></empty:br>Bar.<empty:br></empty:br></container:p>' ) . getFillerOffset ( ) )
84+ . to . equals ( 4 ) ;
85+ } ) ;
86+
87+ it ( 'ignores the ui elements' , ( ) => {
88+ expect ( parse ( '<container:p><ui:span></ui:span><empty:br></empty:br></container:p>' ) . getFillerOffset ( ) )
89+ . to . equals ( 2 ) ;
90+ } ) ;
91+
92+ it ( 'empty element must be the <br> element' , ( ) => {
93+ expect ( parse ( '<container:p>Foo<empty:img></empty:img></container:p>' ) . getFillerOffset ( ) )
94+ . to . equals ( null ) ;
95+ } ) ;
96+ } ) ;
6297 } ) ;
6398} ) ;
0 commit comments