@@ -4,7 +4,12 @@ import {
44 getFragmentParagraphBorders ,
55 computeBetweenBorderFlags ,
66 type BlockLookup ,
7- } from './renderer.js' ;
7+ type BetweenBorderInfo ,
8+ } from './features/paragraph-borders/index.js' ;
9+
10+ /** Helper to create BetweenBorderInfo for tests that previously passed a boolean. */
11+ const betweenOn : BetweenBorderInfo = { showBetweenBorder : true , suppressTopBorder : false , gapBelow : 0 } ;
12+ const betweenOff : BetweenBorderInfo = { showBetweenBorder : false , suppressTopBorder : false , gapBelow : 0 } ;
813import { createDomPainter } from './index.js' ;
914import type {
1015 ParagraphBorders ,
@@ -123,7 +128,7 @@ describe('applyParagraphBorderStyles β between borders', () => {
123128 top : { style : 'solid' , width : 1 , color : '#000' } ,
124129 between : { style : 'solid' , width : 2 , color : '#FF0000' } ,
125130 } ;
126- applyParagraphBorderStyles ( e , borders , false ) ;
131+ applyParagraphBorderStyles ( e , borders , betweenOff ) ;
127132 expect ( e . style . getPropertyValue ( 'border-top-style' ) ) . toBe ( 'solid' ) ;
128133 expect ( e . style . getPropertyValue ( 'border-bottom-style' ) ) . toBe ( '' ) ;
129134 } ) ;
@@ -136,7 +141,7 @@ describe('applyParagraphBorderStyles β between borders', () => {
136141
137142 it ( 'applies between border as bottom border when showBetweenBorder is true' , ( ) => {
138143 const e = el ( ) ;
139- applyParagraphBorderStyles ( e , { between : { style : 'dashed' , width : 3 , color : '#0F0' } } , true ) ;
144+ applyParagraphBorderStyles ( e , { between : { style : 'dashed' , width : 3 , color : '#0F0' } } , betweenOn ) ;
140145 expect ( e . style . getPropertyValue ( 'border-bottom-style' ) ) . toBe ( 'dashed' ) ;
141146 expect ( e . style . getPropertyValue ( 'border-bottom-width' ) ) . toBe ( '3px' ) ;
142147 expect ( e . style . getPropertyValue ( 'border-bottom-color' ) ) . toBe ( '#0F0' ) ;
@@ -148,7 +153,7 @@ describe('applyParagraphBorderStyles β between borders', () => {
148153 applyParagraphBorderStyles (
149154 e ,
150155 { bottom : { style : 'solid' , width : 1 , color : '#000' } , between : { style : 'double' , width : 4 , color : '#F00' } } ,
151- true ,
156+ betweenOn ,
152157 ) ;
153158 expect ( e . style . getPropertyValue ( 'border-bottom-style' ) ) . toBe ( 'double' ) ;
154159 expect ( e . style . getPropertyValue ( 'border-bottom-width' ) ) . toBe ( '4px' ) ;
@@ -160,7 +165,7 @@ describe('applyParagraphBorderStyles β between borders', () => {
160165 applyParagraphBorderStyles (
161166 e ,
162167 { bottom : { style : 'solid' , width : 1 , color : '#000' } , between : { style : 'double' , width : 4 , color : '#F00' } } ,
163- false ,
168+ betweenOff ,
164169 ) ;
165170 expect ( e . style . getPropertyValue ( 'border-bottom-style' ) ) . toBe ( 'solid' ) ;
166171 expect ( e . style . getPropertyValue ( 'border-bottom-width' ) ) . toBe ( '1px' ) ;
@@ -176,7 +181,7 @@ describe('applyParagraphBorderStyles β between borders', () => {
176181 left : { style : 'solid' , width : 1 , color : '#000' } ,
177182 between : { style : 'dashed' , width : 2 , color : '#F00' } ,
178183 } ;
179- applyParagraphBorderStyles ( e , borders , true ) ;
184+ applyParagraphBorderStyles ( e , borders , betweenOn ) ;
180185 expect ( e . style . getPropertyValue ( 'border-top-style' ) ) . toBe ( 'solid' ) ;
181186 expect ( e . style . getPropertyValue ( 'border-right-style' ) ) . toBe ( 'solid' ) ;
182187 expect ( e . style . getPropertyValue ( 'border-left-style' ) ) . toBe ( 'solid' ) ;
@@ -187,59 +192,59 @@ describe('applyParagraphBorderStyles β between borders', () => {
187192 // --- partial / degenerate border specs ---
188193 it ( 'handles between border with none style' , ( ) => {
189194 const e = el ( ) ;
190- applyParagraphBorderStyles ( e , { between : { style : 'none' , width : 0 , color : '#000' } } , true ) ;
195+ applyParagraphBorderStyles ( e , { between : { style : 'none' , width : 0 , color : '#000' } } , betweenOn ) ;
191196 expect ( e . style . getPropertyValue ( 'border-bottom-style' ) ) . toBe ( 'none' ) ;
192197 expect ( e . style . getPropertyValue ( 'border-bottom-width' ) ) . toBe ( '0px' ) ;
193198 } ) ;
194199
195200 it ( 'defaults width to 1px when between border has no width' , ( ) => {
196201 const e = el ( ) ;
197- applyParagraphBorderStyles ( e , { between : { style : 'solid' , color : '#F00' } } , true ) ;
202+ applyParagraphBorderStyles ( e , { between : { style : 'solid' , color : '#F00' } } , betweenOn ) ;
198203 expect ( e . style . getPropertyValue ( 'border-bottom-width' ) ) . toBe ( '1px' ) ;
199204 } ) ;
200205
201206 it ( 'defaults color to #000 when between border has no color' , ( ) => {
202207 const e = el ( ) ;
203- applyParagraphBorderStyles ( e , { between : { style : 'solid' , width : 2 } } , true ) ;
208+ applyParagraphBorderStyles ( e , { between : { style : 'solid' , width : 2 } } , betweenOn ) ;
204209 expect ( e . style . getPropertyValue ( 'border-bottom-color' ) ) . toBe ( '#000' ) ;
205210 } ) ;
206211
207212 it ( 'defaults style to solid when between border has no style' , ( ) => {
208213 const e = el ( ) ;
209- applyParagraphBorderStyles ( e , { between : { width : 2 , color : '#F00' } } , true ) ;
214+ applyParagraphBorderStyles ( e , { between : { width : 2 , color : '#F00' } } , betweenOn ) ;
210215 expect ( e . style . getPropertyValue ( 'border-bottom-style' ) ) . toBe ( 'solid' ) ;
211216 } ) ;
212217
213218 it ( 'handles between border with only width' , ( ) => {
214219 const e = el ( ) ;
215- applyParagraphBorderStyles ( e , { between : { width : 5 } } , true ) ;
220+ applyParagraphBorderStyles ( e , { between : { width : 5 } } , betweenOn ) ;
216221 expect ( e . style . getPropertyValue ( 'border-bottom-style' ) ) . toBe ( 'solid' ) ;
217222 expect ( e . style . getPropertyValue ( 'border-bottom-width' ) ) . toBe ( '5px' ) ;
218223 expect ( e . style . getPropertyValue ( 'border-bottom-color' ) ) . toBe ( '#000' ) ;
219224 } ) ;
220225
221226 it ( 'clamps negative width to 0px' , ( ) => {
222227 const e = el ( ) ;
223- applyParagraphBorderStyles ( e , { between : { style : 'solid' , width : - 3 } } , true ) ;
228+ applyParagraphBorderStyles ( e , { between : { style : 'solid' , width : - 3 } } , betweenOn ) ;
224229 expect ( e . style . getPropertyValue ( 'border-bottom-width' ) ) . toBe ( '0px' ) ;
225230 } ) ;
226231
227232 it ( 'handles width=0 (renders as zero-width border)' , ( ) => {
228233 const e = el ( ) ;
229- applyParagraphBorderStyles ( e , { between : { style : 'solid' , width : 0 } } , true ) ;
234+ applyParagraphBorderStyles ( e , { between : { style : 'solid' , width : 0 } } , betweenOn ) ;
230235 expect ( e . style . getPropertyValue ( 'border-bottom-width' ) ) . toBe ( '0px' ) ;
231236 } ) ;
232237
233238 it ( 'no-ops when showBetweenBorder=true but borders.between is undefined' , ( ) => {
234239 const e = el ( ) ;
235- applyParagraphBorderStyles ( e , { top : { style : 'solid' , width : 1 } } , true ) ;
240+ applyParagraphBorderStyles ( e , { top : { style : 'solid' , width : 1 } } , betweenOn ) ;
236241 // Should not crash, and no bottom border should appear
237242 expect ( e . style . getPropertyValue ( 'border-bottom-style' ) ) . toBe ( '' ) ;
238243 } ) ;
239244
240245 it ( 'no-ops when borders is undefined' , ( ) => {
241246 const e = el ( ) ;
242- applyParagraphBorderStyles ( e , undefined , true ) ;
247+ applyParagraphBorderStyles ( e , undefined , betweenOn ) ;
243248 expect ( e . style . getPropertyValue ( 'border-bottom-style' ) ) . toBe ( '' ) ;
244249 } ) ;
245250} ) ;
@@ -308,7 +313,11 @@ describe('computeBetweenBorderFlags', () => {
308313
309314 const flags = computeBetweenBorderFlags ( fragments , lookup ) ;
310315 expect ( flags . has ( 0 ) ) . toBe ( true ) ;
311- expect ( flags . size ) . toBe ( 1 ) ;
316+ expect ( flags . get ( 0 ) ?. showBetweenBorder ) . toBe ( true ) ;
317+ // Fragment 1 also gets an entry (suppressTopBorder)
318+ expect ( flags . has ( 1 ) ) . toBe ( true ) ;
319+ expect ( flags . get ( 1 ) ?. suppressTopBorder ) . toBe ( true ) ;
320+ expect ( flags . size ) . toBe ( 2 ) ;
312321 } ) ;
313322
314323 it ( 'does not flag when between border is not defined' , ( ) => {
@@ -436,8 +445,14 @@ describe('computeBetweenBorderFlags', () => {
436445
437446 const flags = computeBetweenBorderFlags ( fragments , lookup ) ;
438447 expect ( flags . has ( 0 ) ) . toBe ( true ) ;
448+ expect ( flags . get ( 0 ) ?. showBetweenBorder ) . toBe ( true ) ;
439449 expect ( flags . has ( 1 ) ) . toBe ( true ) ;
440- expect ( flags . size ) . toBe ( 2 ) ;
450+ expect ( flags . get ( 1 ) ?. showBetweenBorder ) . toBe ( true ) ;
451+ expect ( flags . get ( 1 ) ?. suppressTopBorder ) . toBe ( true ) ;
452+ expect ( flags . has ( 2 ) ) . toBe ( true ) ;
453+ expect ( flags . get ( 2 ) ?. suppressTopBorder ) . toBe ( true ) ;
454+ expect ( flags . get ( 2 ) ?. showBetweenBorder ) . toBe ( false ) ;
455+ expect ( flags . size ) . toBe ( 3 ) ;
441456 } ) ;
442457
443458 it ( 'breaks chain when middle paragraph has different borders' , ( ) => {
0 commit comments