@@ -111,7 +111,8 @@ test('recursive theme replacements', () => {
111
111
}
112
112
113
113
expect ( replaceCssVarsWithFallbacks ( state , 'var(--color-a)' ) ) . toBe ( 'var(--color-a)' )
114
- expect ( replaceCssVarsWithFallbacks ( state , 'var(--color-b)' ) ) . toBe ( 'rgb(var(--color-b))' )
114
+ // TODO: -> rgb(var(--color-b))
115
+ expect ( replaceCssVarsWithFallbacks ( state , 'var(--color-b)' ) ) . toBe ( 'var(--color-b)' )
115
116
expect ( replaceCssVarsWithFallbacks ( state , 'var(--color-c)' ) ) . toBe ( 'rgb(255 255 255)' )
116
117
117
118
// This one is wrong but fixing it without breaking the infinite recursion guard is complex
@@ -152,7 +153,8 @@ test('recursive theme replacements (inlined)', () => {
152
153
}
153
154
154
155
expect ( inlineThemeValues ( 'var(--color-a)' , state ) ) . toBe ( 'var(--color-a)' )
155
- expect ( inlineThemeValues ( 'var(--color-b)' , state ) ) . toBe ( 'rgb(var(--color-b))' )
156
+ // TODO: -> rgb(var(--color-b))
157
+ expect ( inlineThemeValues ( 'var(--color-b)' , state ) ) . toBe ( 'var(--color-b)' )
156
158
expect ( inlineThemeValues ( 'var(--color-c)' , state ) ) . toBe ( 'rgb(255 255 255)' )
157
159
158
160
// This one is wrong but fixing it without breaking the infinite recursion guard is complex
@@ -192,6 +194,9 @@ test('Inlining calc expressions using the design system', () => {
192
194
[ '--spacing' , '0.25rem' ] ,
193
195
[ '--color-red-500' , 'oklch(0.637 0.237 25.331)' ] ,
194
196
[ '--font-size.md' , '1rem' ] ,
197
+ [ '--wrapped' , 'calc(var(--wrapped))' ] ,
198
+ [ '--unbalanced-1' , 'calc(var(--unbalanced-1)' ] ,
199
+ [ '--unbalanced-2' , 'calc(1px + 2px' ] ,
195
200
] )
196
201
197
202
let state : State = {
@@ -246,4 +251,31 @@ test('Inlining calc expressions using the design system', () => {
246
251
expect ( addThemeValues ( 'var(--font-size\\.md)' , state , settings ) ) . toBe (
247
252
'var(--font-size\\.md) /* 1rem = 10px */' ,
248
253
)
254
+
255
+ // Variables that replace with themselves. This could be handled better
256
+ expect ( addThemeValues ( 'calc(var(--wrapped))' , state , settings ) ) . toBe (
257
+ 'calc(var(--wrapped) /* calc(var(--wrapped)) */)' ,
258
+ )
259
+ expect ( addThemeValues ( 'var(--wrapped)' , state , settings ) ) . toBe (
260
+ 'var(--wrapped) /* calc(var(--wrapped)) */' ,
261
+ )
262
+
263
+ // Unbalanced calc expressions. Whether or not these "work" is undefined. If
264
+ // these change results that's okay.
265
+ expect ( addThemeValues ( 'calc(var(--unbalanced-1))' , state , settings ) ) . toBe (
266
+ 'calc(var(--unbalanced-1) /* calc(var(--unbalanced-1) */)' ,
267
+ )
268
+ expect ( addThemeValues ( 'var(--unbalanced-1)' , state , settings ) ) . toBe (
269
+ 'var(--unbalanced-1) /* calc(var(--unbalanced-1) */' ,
270
+ )
271
+
272
+ // It would be fine for either of these to not replace at all
273
+ expect ( addThemeValues ( 'calc(var(--unbalanced-2))' , state , settings ) ) . toBe (
274
+ 'calc(var(--unbalanced-2)) /* 3px */' ,
275
+ )
276
+ expect ( addThemeValues ( 'var(--unbalanced-2)' , state , settings ) ) . toBe (
277
+ 'var(--unbalanced-2) /* calc(1px + 2px */' ,
278
+ )
279
+
280
+ expect ( addThemeValues ( 'calc(1 + 2' , state , settings ) ) . toBe ( 'calc(1 + 2' )
249
281
} )
0 commit comments