File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,3 +49,43 @@ describe('generateMonolithSTL', () => {
4949 expect ( stl ) . toContain ( 'endsolid commitpulse_monolith' ) ;
5050 } ) ;
5151} ) ;
52+
53+ it ( 'generates structurally valid ASCII STL facets' , ( ) => {
54+ const mockTowers : TowerData [ ] = [
55+ {
56+ x : 0 ,
57+ y : 0 ,
58+ h : 10 ,
59+ hasCommits : true ,
60+ isGhost : false ,
61+ isToday : false ,
62+ isTodayWithCommits : false ,
63+ tooltip : '' ,
64+ contributionCount : 5 ,
65+ faceOpacity : { left : 1 , right : 1 , top : 1 } ,
66+ strokeOpacity : 1 ,
67+ strokeWidth : 1 ,
68+ row : 0 ,
69+ col : 0 ,
70+ } ,
71+ ] ;
72+
73+ const stl = generateMonolithSTL ( mockTowers ) ;
74+
75+ const facetCount = ( stl . match ( / f a c e t n o r m a l / g) ?? [ ] ) . length ;
76+ const endFacetCount = ( stl . match ( / e n d f a c e t / g) ?? [ ] ) . length ;
77+
78+ const outerLoopCount = ( stl . match ( / o u t e r l o o p / g) ?? [ ] ) . length ;
79+ const endLoopCount = ( stl . match ( / e n d l o o p / g) ?? [ ] ) . length ;
80+
81+ expect ( facetCount ) . toBe ( endFacetCount ) ;
82+ expect ( outerLoopCount ) . toBe ( endLoopCount ) ;
83+
84+ const vertexLines = stl . split ( '\n' ) . filter ( ( line ) => line . trim ( ) . startsWith ( 'vertex' ) ) ;
85+
86+ expect ( vertexLines . length ) . toBeGreaterThan ( 0 ) ;
87+
88+ vertexLines . forEach ( ( line ) => {
89+ expect ( line . trim ( ) ) . toMatch ( / ^ v e r t e x - ? \d + \. \d + - ? \d + \. \d + - ? \d + \. \d + $ / ) ;
90+ } ) ;
91+ } ) ;
You can’t perform that action at this time.
0 commit comments