@@ -32,6 +32,38 @@ describe('round-trip: builder output parses back into app format', () => {
3232 expect ( parsedClassic . stops . length ) . toBeGreaterThan ( 1 )
3333 } )
3434
35+ it ( 'preserves explicit span positions for stripe-style presets' , ( ) => {
36+ // Match the structure of the "Stripes" preset as a single layer
37+ const stripes = makeLayer ( {
38+ type : 'linear' ,
39+ space : 'oklab' ,
40+ linear : { named_angle : 'to right top' , angle : null } ,
41+ stops : [
42+ stop ( '#fff' ) , // leading white, no positions
43+ hint ( 0 ) , // midpoint (auto-managed)
44+ stop ( '#000' , 0 , 20 ) ,
45+ hint ( 0 ) ,
46+ stop ( '#fff' , 0 , 40 ) ,
47+ hint ( 0 ) ,
48+ stop ( '#000' , 0 , 60 ) ,
49+ hint ( 0 ) ,
50+ stop ( '#fff' , 0 , 80 ) ,
51+ hint ( 0 ) ,
52+ stop ( '#000' , 0 , 100 ) ,
53+ ] ,
54+ } )
55+
56+ const { modern } = buildGradientStrings ( stripes as any )
57+
58+ // The output should contain both start and end positions for each black/white span,
59+ // not collapse them down to a single 0% position.
60+ expect ( modern . replace ( / \s + / g, ' ' ) ) . toContain ( '#000 0% 20%' )
61+ expect ( modern . replace ( / \s + / g, ' ' ) ) . toContain ( '#fff 0% 40%' )
62+ expect ( modern . replace ( / \s + / g, ' ' ) ) . toContain ( '#000 0% 60%' )
63+ expect ( modern . replace ( / \s + / g, ' ' ) ) . toContain ( '#fff 0% 80%' )
64+ expect ( modern . replace ( / \s + / g, ' ' ) ) . toContain ( '#000 0% 100%' )
65+ } )
66+
3567 it ( 'radial and conic builder outputs also parse successfully' , ( ) => {
3668 const radial = makeLayer ( { type : 'radial' , radial : { shape : 'circle' , size : 'farthest-corner' , named_position : 'center' , position : { x : 50 , y : 50 } } as any } )
3769 const conic = makeLayer ( { type : 'conic' , conic : { angle : 0 , named_position : 'center' , position : { x : 50 , y : 50 } } as any } )
0 commit comments