@@ -328,4 +328,81 @@ describe('Color Utilities', () => {
328328 expect ( gen . toCSS ( ) ) . toContain ( 'color: currentColor;' )
329329 } )
330330 } )
331+
332+ describe ( 'Advanced color formats' , ( ) => {
333+ it ( 'should handle 3-digit hex colors' , ( ) => {
334+ const gen = new CSSGenerator ( defaultConfig )
335+ gen . generate ( 'bg-[#fff]' )
336+ gen . generate ( 'text-[#000]' )
337+ const css = gen . toCSS ( )
338+ expect ( css ) . toContain ( '#fff' )
339+ expect ( css ) . toContain ( '#000' )
340+ } )
341+
342+ it ( 'should handle 8-digit hex colors with alpha' , ( ) => {
343+ const gen = new CSSGenerator ( defaultConfig )
344+ gen . generate ( 'bg-[#ff000080]' )
345+ const css = gen . toCSS ( )
346+ expect ( css ) . toContain ( '#ff000080' )
347+ } )
348+
349+ it ( 'should handle rgb() notation' , ( ) => {
350+ const gen = new CSSGenerator ( defaultConfig )
351+ gen . generate ( 'bg-[rgb(255,0,0)]' )
352+ const css = gen . toCSS ( )
353+ expect ( css ) . toContain ( 'rgb(255,0,0)' )
354+ } )
355+
356+ it ( 'should handle rgba() notation' , ( ) => {
357+ const gen = new CSSGenerator ( defaultConfig )
358+ gen . generate ( 'bg-[rgba(255,0,0,0.5)]' )
359+ const css = gen . toCSS ( )
360+ expect ( css ) . toContain ( 'rgba(255,0,0,0.5)' )
361+ } )
362+
363+ it ( 'should handle hsl() notation' , ( ) => {
364+ const gen = new CSSGenerator ( defaultConfig )
365+ gen . generate ( 'bg-[hsl(0,100%,50%)]' )
366+ const css = gen . toCSS ( )
367+ expect ( css ) . toContain ( 'hsl(0,100%,50%)' )
368+ } )
369+
370+ it ( 'should handle hsla() notation' , ( ) => {
371+ const gen = new CSSGenerator ( defaultConfig )
372+ gen . generate ( 'bg-[hsla(0,100%,50%,0.5)]' )
373+ const css = gen . toCSS ( )
374+ expect ( css ) . toContain ( 'hsla(0,100%,50%,0.5)' )
375+ } )
376+
377+ it ( 'should handle oklch() notation' , ( ) => {
378+ const gen = new CSSGenerator ( defaultConfig )
379+ gen . generate ( 'bg-[oklch(0.5_0.2_180)]' )
380+ const css = gen . toCSS ( )
381+ expect ( css ) . toContain ( 'oklch' )
382+ } )
383+
384+ it ( 'should handle color() notation' , ( ) => {
385+ const gen = new CSSGenerator ( defaultConfig )
386+ gen . generate ( 'bg-[color(display-p3_1_0_0)]' )
387+ const css = gen . toCSS ( )
388+ expect ( css ) . toContain ( 'color(' )
389+ } )
390+
391+ it ( 'should handle nonexistent color shades gracefully' , ( ) => {
392+ const gen = new CSSGenerator ( defaultConfig )
393+ gen . generate ( 'bg-blue-999' )
394+ gen . generate ( 'text-red-1' )
395+ // Should not crash, may not generate CSS
396+ expect ( ( ) => gen . toCSS ( ) ) . not . toThrow ( )
397+ } )
398+
399+ it ( 'should handle color with opacity modifier' , ( ) => {
400+ const gen = new CSSGenerator ( defaultConfig )
401+ gen . generate ( 'bg-blue-500/50' )
402+ gen . generate ( 'text-red-500/75' )
403+ const css = gen . toCSS ( )
404+ // May or may not be implemented, but should not crash
405+ expect ( ( ) => gen . toCSS ( ) ) . not . toThrow ( )
406+ } )
407+ } )
331408 } )
0 commit comments