@@ -83,6 +83,10 @@ function renderComponent(element: React.ReactElement): string {
8383 return ReactDOMServer . renderToStaticMarkup ( element )
8484}
8585
86+ function countPattern ( html : string , pattern : RegExp ) : number {
87+ return ( html . match ( pattern ) || [ ] ) . length
88+ }
89+
8690function countOccurrences ( html : string , tag : string ) : number {
8791 const regex = new RegExp ( `<${ tag } [\\s/>]` , "g" )
8892 return ( html . match ( regex ) || [ ] ) . length
@@ -924,9 +928,10 @@ describe("Component SSR — ConnectedScatterplot", () => {
924928 />
925929 )
926930
927- // svgPreRenderers should produce <line> elements connecting points
928- // 5 points = 4 connecting segments
929- expect ( countOccurrences ( html , "line" ) ) . toBeGreaterThanOrEqual ( 4 )
931+ // Connecting segments use stroke-linecap="round" — unique to svgPreRenderer lines
932+ // 5 points = 4 connecting segments (each with stroke-linecap="round")
933+ const roundCapLines = countPattern ( html , / s t r o k e - l i n e c a p = " r o u n d " / g)
934+ expect ( roundCapLines ) . toBeGreaterThanOrEqual ( 4 )
930935 } )
931936
932937 it ( "renders halo lines when fewer than 100 points" , ( ) => {
@@ -940,10 +945,10 @@ describe("Component SSR — ConnectedScatterplot", () => {
940945 />
941946 )
942947
943- // Halo lines (white stroke) + segment lines = 8 total for 5 points
944- // At minimum, more lines than just segments
945- const lineCount = countOccurrences ( html , "line" )
946- expect ( lineCount ) . toBeGreaterThanOrEqual ( 8 ) // 4 halos + 4 segments
948+ // Halo lines have stroke="white" + stroke-linecap="round"
949+ // 5 points = 4 halos
950+ const haloLines = countPattern ( html , / s t r o k e = " w h i t e " [ ^ > ] * s t r o k e - l i n e c a p = " r o u n d " / g )
951+ expect ( haloLines ) . toBe ( 4 )
947952 } )
948953
949954 it ( "applies viridis colors to connecting segments" , ( ) => {
@@ -957,8 +962,9 @@ describe("Component SSR — ConnectedScatterplot", () => {
957962 />
958963 )
959964
960- // Viridis colors are hex strings like #440154 — segments should have stroke attributes
961- expect ( html ) . toMatch ( / s t r o k e = " # [ 0 - 9 a - f ] { 6 } " / i)
965+ // Connecting segments have hex stroke + stroke-linecap="round" (unique to pre-renderer)
966+ const viridisSegments = countPattern ( html , / s t r o k e = " # [ 0 - 9 a - f ] { 6 } " [ ^ > ] * s t r o k e - l i n e c a p = " r o u n d " / gi)
967+ expect ( viridisSegments ) . toBe ( 4 ) // 4 connecting segments
962968 } )
963969
964970 it ( "respects orderAccessor for sorting" , ( ) => {
@@ -980,9 +986,9 @@ describe("Component SSR — ConnectedScatterplot", () => {
980986 />
981987 )
982988
983- // Should still render circles and connecting lines
989+ // Should still render circles and round-capped connecting lines
984990 expect ( countOccurrences ( html , "circle" ) ) . toBeGreaterThanOrEqual ( 5 )
985- expect ( countOccurrences ( html , "line" ) ) . toBeGreaterThanOrEqual ( 4 )
991+ expect ( countPattern ( html , / s t r o k e - l i n e c a p = " r o u n d " / g ) ) . toBeGreaterThanOrEqual ( 4 )
986992 } )
987993} )
988994
@@ -1052,8 +1058,9 @@ describe("Component SSR — QuadrantChart", () => {
10521058 />
10531059 )
10541060
1055- // 2 center lines (vertical + horizontal)
1056- expect ( countOccurrences ( html , "line" ) ) . toBeGreaterThanOrEqual ( 2 )
1061+ // 2 center lines (vertical + horizontal) with default stroke="#999"
1062+ const centerLines = countPattern ( html , / s t r o k e = " # 9 9 9 " / g)
1063+ expect ( centerLines ) . toBe ( 2 )
10571064 } )
10581065
10591066 it ( "renders quadrant labels when showQuadrantLabels is true" , ( ) => {
0 commit comments