@@ -7,7 +7,7 @@ const os = require('os');
77// This file is the entry point for the react-zero-ui library, that uses postcss to trigger the build process
88const plugin = require ( '../../dist/postcss/index.cjs' ) ;
99
10- const { patchConfigAlias , toKebabCase, patchPostcssConfig, patchViteConfig } = require ( '../../dist/postcss/helpers.cjs' ) ;
10+ const { patchTsConfig , toKebabCase, patchPostcssConfig, patchViteConfig } = require ( '../../dist/postcss/helpers.cjs' ) ;
1111
1212function getAttrFile ( ) {
1313 return path . join ( process . cwd ( ) , '.zero-ui' , 'attributes.js' ) ;
@@ -68,7 +68,6 @@ test('generates body attributes file correctly', async () => {
6868 // Read and parse attributes
6969 const content = fs . readFileSync ( getAttrFile ( ) , 'utf-8' ) ;
7070 console . log ( '\n📄 Generated attributes file:' ) ;
71- console . log ( content ) ;
7271
7372 // Verify content
7473 assert ( content . includes ( 'export const bodyAttributes' ) , 'Should export bodyAttributes' ) ;
@@ -104,7 +103,6 @@ test('generates body attributes file correctly when kebab-case is used', async (
104103 assert ( fs . existsSync ( getAttrFile ( ) ) , 'Attributes file should exist' ) ;
105104
106105 const content = fs . readFileSync ( getAttrFile ( ) , 'utf-8' ) ;
107- console . log ( 'result.css: ' , result . css ) ;
108106
109107 // Verify content
110108 assert ( content . includes ( 'export const bodyAttributes' ) , 'Should export bodyAttributes' ) ;
@@ -318,9 +316,9 @@ test('handles multiple files and deduplication', async () => {
318316 ) ;
319317} ) ;
320318
321- test ( 'handles parsing errors gracefully ' , async ( ) => {
322- await runTest (
323- {
319+ test ( 'throws on invalid syntax ' , async ( ) => {
320+ await assert . rejects ( async ( ) => {
321+ await runTest ( {
324322 'src/valid.jsx' : `
325323 import { useUI } from '@react-zero-ui/core';
326324 function Valid() {
@@ -335,16 +333,8 @@ test('handles parsing errors gracefully', async () => {
335333 {{{ invalid syntax
336334 }
337335 ` ,
338- } ,
339- ( result ) => {
340- console . log ( '\n🔍 Parse Error Test:' ) ;
341- // Should still process valid files
342- assert ( result . css . includes ( '@custom-variant valid-working' ) , 'Should process valid files' ) ;
343-
344- // Should not crash on invalid files
345- assert ( result . css . includes ( 'AUTO-GENERATED' ) , 'Should complete processing' ) ;
346- }
347- ) ;
336+ } ) ;
337+ } , / U n e x p e c t e d t o k e n , e x p e c t e d " , " / ) ;
348338} ) ;
349339
350340test ( 'throws on empty string initial value' , ( ) => {
@@ -559,7 +549,7 @@ test('handles concurrent file modifications', async () => {
559549 ) ;
560550} ) ;
561551
562- test ( 'patchConfigAlias - config file patching' , async ( t ) => {
552+ test ( 'patchTsConfig - config file patching' , async ( t ) => {
563553 await t . test ( 'patches tsconfig.json when it exists' , async ( ) => {
564554 const testDir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , 'zero-ui-config-test' ) ) ;
565555 const originalCwd = process . cwd ( ) ;
@@ -571,8 +561,8 @@ test('patchConfigAlias - config file patching', async (t) => {
571561 const tsconfigContent = { compilerOptions : { target : 'ES2015' , module : 'ESNext' } } ;
572562 fs . writeFileSync ( 'tsconfig.json' , JSON . stringify ( tsconfigContent , null , 2 ) ) ;
573563
574- // Run patchConfigAlias
575- patchConfigAlias ( ) ;
564+ // Run patchTsConfig
565+ patchTsConfig ( ) ;
576566
577567 // Read the updated config
578568 const updatedConfig = JSON . parse ( fs . readFileSync ( 'tsconfig.json' , 'utf-8' ) ) ;
@@ -600,8 +590,8 @@ test('patchConfigAlias - config file patching', async (t) => {
600590 const jsconfigContent = { compilerOptions : { target : 'ES2015' } } ;
601591 fs . writeFileSync ( 'jsconfig.json' , JSON . stringify ( jsconfigContent , null , 2 ) ) ;
602592
603- // Run patchConfigAlias
604- patchConfigAlias ( ) ;
593+ // Run patchTsConfig
594+ patchTsConfig ( ) ;
605595
606596 // Read the updated config
607597 const updatedConfig = JSON . parse ( fs . readFileSync ( 'jsconfig.json' , 'utf-8' ) ) ;
@@ -626,8 +616,8 @@ test('patchConfigAlias - config file patching', async (t) => {
626616 try {
627617 process . chdir ( testDir ) ;
628618
629- // Run patchConfigAlias (should not throw)
630- patchConfigAlias ( ) ;
619+ // Run patchTsConfig (should not throw)
620+ patchTsConfig ( ) ;
631621
632622 // Verify no files were created
633623 assert ( ! fs . existsSync ( 'tsconfig.json' ) , 'Should not create tsconfig.json' ) ;
@@ -656,8 +646,8 @@ test('patchConfigAlias - config file patching', async (t) => {
656646 fs . writeFileSync ( 'tsconfig.json' , JSON . stringify ( tsconfigContent , null , 2 ) ) ;
657647 const originalContent = fs . readFileSync ( 'tsconfig.json' , 'utf-8' ) ;
658648
659- // Run patchConfigAlias
660- patchConfigAlias ( ) ;
649+ // Run patchTsConfig
650+ patchTsConfig ( ) ;
661651
662652 // Verify the config was not modified
663653 const updatedContent = fs . readFileSync ( 'tsconfig.json' , 'utf-8' ) ;
@@ -679,8 +669,8 @@ test('patchConfigAlias - config file patching', async (t) => {
679669 const tsconfigContent = { include : [ 'src/**/*' ] } ;
680670 fs . writeFileSync ( 'tsconfig.json' , JSON . stringify ( tsconfigContent , null , 2 ) ) ;
681671
682- // Run patchConfigAlias
683- patchConfigAlias ( ) ;
672+ // Run patchTsConfig
673+ patchTsConfig ( ) ;
684674
685675 // Read the updated config
686676 const updatedConfig = JSON . parse ( fs . readFileSync ( 'tsconfig.json' , 'utf-8' ) ) ;
@@ -717,8 +707,8 @@ test('patchConfigAlias - config file patching', async (t) => {
717707}` ;
718708 fs . writeFileSync ( 'tsconfig.json' , tsconfigContent ) ;
719709
720- // Run patchConfigAlias
721- patchConfigAlias ( ) ;
710+ // Run patchTsConfig
711+ patchTsConfig ( ) ;
722712
723713 // Verify file was updated (should parse despite comments)
724714 const updatedConfig = JSON . parse ( fs . readFileSync ( 'tsconfig.json' , 'utf-8' ) ) ;
@@ -733,7 +723,7 @@ test('patchConfigAlias - config file patching', async (t) => {
733723 }
734724 } ) ;
735725
736- await t . test ( 'patchConfigAlias prefers tsconfig.json over jsconfig.json' , async ( ) => {
726+ await t . test ( 'patchTsConfig prefers tsconfig.json over jsconfig.json' , async ( ) => {
737727 const testDir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , 'zero-ui-config-test' ) ) ;
738728 const originalCwd = process . cwd ( ) ;
739729
@@ -744,8 +734,8 @@ test('patchConfigAlias - config file patching', async (t) => {
744734 fs . writeFileSync ( 'tsconfig.json' , JSON . stringify ( { compilerOptions : { } } , null , 2 ) ) ;
745735 fs . writeFileSync ( 'jsconfig.json' , JSON . stringify ( { compilerOptions : { } } , null , 2 ) ) ;
746736
747- // Run patchConfigAlias
748- patchConfigAlias ( ) ;
737+ // Run patchTsConfig
738+ patchTsConfig ( ) ;
749739
750740 // Verify tsconfig.json was modified
751741 const tsconfigContent = JSON . parse ( fs . readFileSync ( 'tsconfig.json' , 'utf-8' ) ) ;
@@ -1464,7 +1454,6 @@ test('generated variants for initial value without setterFn', async () => {
14641454 } ,
14651455 ( result ) => {
14661456 console . log ( '\n📄 Initial value without setterFn:' ) ;
1467- console . log ( result . css ) ;
14681457
14691458 assert ( result . css . includes ( '@custom-variant theme-light' ) ) ;
14701459 }
@@ -1491,9 +1480,8 @@ test('handles complex string boolean toggle patterns', async () => {
14911480 ` ,
14921481 } ,
14931482 ( result ) => {
1494- const content = fs . readFileSync ( getAttrFile ( ) , 'utf-8' ) ;
1483+ // const content = fs.readFileSync(getAttrFile(), 'utf-8');
14951484 console . log ( '\n📄 String boolean edge cases:' ) ;
1496- console . log ( content ) ;
14971485
14981486 // Should only have true/false variants for string booleans
14991487 assert ( result . css . includes ( '@custom-variant modal-visible-true' ) ) ;
@@ -1549,7 +1537,6 @@ test.skip('extracts values from deeply nested function calls', async () => {
15491537 } ,
15501538 ( result ) => {
15511539 console . log ( '\n📄 Nested calls extraction:' ) ;
1552- console . log ( result . css ) ;
15531540
15541541 // Should extract all literal values
15551542 assert ( result . css . includes ( '@custom-variant theme-light' ) ) ; // initial
@@ -1587,7 +1574,7 @@ test('handles ternary and logical expressions', async () => {
15871574
15881575 // Logical expressions
15891576 const handleError = () => {
1590- setStatus(error && 'error' || 'success');
1577+ setStatus(hasError && 'error' || 'success');
15911578 };
15921579
15931580 // Complex logical
@@ -1601,11 +1588,11 @@ test('handles ternary and logical expressions', async () => {
16011588 } ,
16021589 ( result ) => {
16031590 console . log ( '\n📄 Expression handling:' ) ;
1604- console . log ( result . css ) ;
16051591
16061592 // Ternary values
16071593 assert ( result . css . includes ( '@custom-variant status-loading' ) ) ;
16081594 assert ( result . css . includes ( '@custom-variant status-ready' ) ) ;
1595+ assert ( result . css . includes ( '@custom-variant status-idle' ) ) ;
16091596 assert ( result . css . includes ( '@custom-variant status-error' ) ) ;
16101597 assert ( result . css . includes ( '@custom-variant status-success' ) ) ;
16111598
@@ -1655,7 +1642,6 @@ export function Pages() {
16551642 } ,
16561643 ( result ) => {
16571644 console . log ( '\n📄 Constants:' ) ;
1658- console . log ( result . css ) ;
16591645
16601646 assert ( result . css . includes ( '@custom-variant theme-dark' ) ) ;
16611647 assert ( result . css . includes ( '@custom-variant theme-default' ) ) ;
@@ -1710,7 +1696,6 @@ test('resolves constants and imported values -- COMPLEX --', async () => {
17101696 } ,
17111697 ( result ) => {
17121698 console . log ( '\n📄 Constants resolution:' ) ;
1713- console . log ( result . css ) ;
17141699
17151700 // Should resolve local constants
17161701 assert ( result . css . includes ( '@custom-variant theme-pending-state' ) ) ;
@@ -1765,7 +1750,6 @@ test.skip('handles all common setter patterns - full coverage sanity check - COM
17651750 } ,
17661751 ( result ) => {
17671752 console . log ( '\n📄 Full coverage test:' ) ;
1768- console . log ( result . css ) ;
17691753
17701754 // ✅ things that MUST be included
17711755 assert ( result . css . includes ( '@custom-variant theme-dark' ) ) ;
@@ -1822,7 +1806,6 @@ test('handles arrow functions and function expressions', async () => {
18221806 } ,
18231807 ( result ) => {
18241808 console . log ( '\n📄 Function expressions:' ) ;
1825- console . log ( result . css ) ;
18261809
18271810 assert ( result . css . includes ( '@custom-variant component-state-quick' ) ) ;
18281811 assert ( result . css . includes ( '@custom-variant component-state-block' ) ) ;
@@ -1862,7 +1845,6 @@ test('handles multiple setters for same state key', async () => {
18621845 } ,
18631846 ( result ) => {
18641847 console . log ( '\n📄 Multiple setters:' ) ;
1865- console . log ( result . css ) ;
18661848
18671849 // Should combine all values from different setters for same key
18681850 assert ( result . css . includes ( '@custom-variant global-theme-light' ) ) ;
@@ -1904,7 +1886,6 @@ test('ignores dynamic and non-literal values', async () => {
19041886 } ,
19051887 ( result ) => {
19061888 console . log ( '\n📄 Dynamic values filtering:' ) ;
1907- console . log ( result . css ) ;
19081889
19091890 // Should only have literals
19101891 assert ( result . css . includes ( '@custom-variant theme-default' ) ) ; // initial
@@ -1958,9 +1939,6 @@ test('handles edge cases with unusual syntax', async () => {
19581939 ` ,
19591940 } ,
19601941 ( result ) => {
1961- console . log ( '\n📄 Edge cases:' ) ;
1962- console . log ( result . css ) ;
1963-
19641942 // Basic cases that should work
19651943 assert ( result . css . includes ( '@custom-variant edge-state-first' ) ) ;
19661944 assert ( result . css . includes ( '@custom-variant edge-state-second' ) ) ;
0 commit comments