@@ -1068,6 +1068,59 @@ describe('generateComponentUsage', () => {
10681068 expect ( result ) . toBe ( '<ButtonSet variant="primary" size="lg" />' )
10691069 } )
10701070
1071+ it ( 'should include BOOLEAN and TEXT from parent COMPONENT_SET for COMPONENT' , ( ) => {
1072+ const componentSet = {
1073+ type : 'COMPONENT_SET' ,
1074+ name : 'Menu' ,
1075+ componentPropertyDefinitions : {
1076+ effect : {
1077+ type : 'VARIANT' ,
1078+ defaultValue : 'default' ,
1079+ variantOptions : [ 'default' , 'hover' ] ,
1080+ } ,
1081+ 'link#70:456' : {
1082+ type : 'BOOLEAN' ,
1083+ defaultValue : true ,
1084+ } ,
1085+ 'text#80:456' : {
1086+ type : 'TEXT' ,
1087+ defaultValue : '텍스트' ,
1088+ } ,
1089+ } ,
1090+ }
1091+ const node = {
1092+ type : 'COMPONENT' ,
1093+ name : 'effect=default' ,
1094+ variantProperties : { effect : 'default' } ,
1095+ parent : componentSet ,
1096+ } as unknown as SceneNode
1097+
1098+ const result = codeModule . generateComponentUsage ( node )
1099+ expect ( result ) . toBe ( '<Menu link>텍스트</Menu>' )
1100+ } )
1101+
1102+ it ( 'should skip BOOLEAN with false default from parent COMPONENT_SET for COMPONENT' , ( ) => {
1103+ const componentSet = {
1104+ type : 'COMPONENT_SET' ,
1105+ name : 'Menu' ,
1106+ componentPropertyDefinitions : {
1107+ 'link#70:456' : {
1108+ type : 'BOOLEAN' ,
1109+ defaultValue : false ,
1110+ } ,
1111+ } ,
1112+ }
1113+ const node = {
1114+ type : 'COMPONENT' ,
1115+ name : 'effect=default' ,
1116+ variantProperties : { effect : 'default' } ,
1117+ parent : componentSet ,
1118+ } as unknown as SceneNode
1119+
1120+ const result = codeModule . generateComponentUsage ( node )
1121+ expect ( result ) . toBe ( '<Menu />' )
1122+ } )
1123+
10711124 it ( 'should generate usage for COMPONENT_SET with defaults' , ( ) => {
10721125 const node = {
10731126 type : 'COMPONENT_SET' ,
@@ -1129,7 +1182,7 @@ describe('generateComponentUsage', () => {
11291182 expect ( result ) . toBe ( '<MyButton variant="primary" />' )
11301183 } )
11311184
1132- it ( 'should skip non-VARIANT properties for COMPONENT_SET' , ( ) => {
1185+ it ( 'should include BOOLEAN and TEXT properties for COMPONENT_SET' , ( ) => {
11331186 const node = {
11341187 type : 'COMPONENT_SET' ,
11351188 name : 'MyButton' ,
@@ -1150,10 +1203,199 @@ describe('generateComponentUsage', () => {
11501203 } ,
11511204 } as unknown as SceneNode
11521205
1206+ const result = codeModule . generateComponentUsage ( node )
1207+ expect ( result ) . toBe ( '<MyButton variant="primary" hasIcon />' )
1208+ } )
1209+
1210+ it ( 'should skip BOOLEAN with false defaultValue for COMPONENT_SET' , ( ) => {
1211+ const node = {
1212+ type : 'COMPONENT_SET' ,
1213+ name : 'MyButton' ,
1214+ componentPropertyDefinitions : {
1215+ variant : {
1216+ type : 'VARIANT' ,
1217+ defaultValue : 'primary' ,
1218+ variantOptions : [ 'primary' , 'secondary' ] ,
1219+ } ,
1220+ hasIcon : {
1221+ type : 'BOOLEAN' ,
1222+ defaultValue : false ,
1223+ } ,
1224+ } ,
1225+ } as unknown as SceneNode
1226+
11531227 const result = codeModule . generateComponentUsage ( node )
11541228 expect ( result ) . toBe ( '<MyButton variant="primary" />' )
11551229 } )
11561230
1231+ it ( 'should include TEXT properties for COMPONENT_SET' , ( ) => {
1232+ const node = {
1233+ type : 'COMPONENT_SET' ,
1234+ name : 'MyButton' ,
1235+ componentPropertyDefinitions : {
1236+ variant : {
1237+ type : 'VARIANT' ,
1238+ defaultValue : 'primary' ,
1239+ variantOptions : [ 'primary' , 'secondary' ] ,
1240+ } ,
1241+ 'label#80:456' : {
1242+ type : 'TEXT' ,
1243+ defaultValue : 'Click me' ,
1244+ } ,
1245+ } ,
1246+ } as unknown as SceneNode
1247+
1248+ const result = codeModule . generateComponentUsage ( node )
1249+ expect ( result ) . toBe ( '<MyButton variant="primary">Click me</MyButton>' )
1250+ } )
1251+
1252+ it ( 'should use children syntax for COMPONENT with VARIANT and single TEXT' , ( ) => {
1253+ const componentSet = {
1254+ type : 'COMPONENT_SET' ,
1255+ name : 'Menu' ,
1256+ componentPropertyDefinitions : {
1257+ size : {
1258+ type : 'VARIANT' ,
1259+ defaultValue : 'md' ,
1260+ variantOptions : [ 'sm' , 'md' ] ,
1261+ } ,
1262+ 'text#80:456' : {
1263+ type : 'TEXT' ,
1264+ defaultValue : '텍스트' ,
1265+ } ,
1266+ } ,
1267+ }
1268+ const node = {
1269+ type : 'COMPONENT' ,
1270+ name : 'size=md' ,
1271+ variantProperties : { size : 'md' } ,
1272+ parent : componentSet ,
1273+ } as unknown as SceneNode
1274+
1275+ const result = codeModule . generateComponentUsage ( node )
1276+ expect ( result ) . toBe ( '<Menu size="md">텍스트</Menu>' )
1277+ } )
1278+
1279+ it ( 'should use children syntax for COMPONENT with single TEXT-only prop (no other props)' , ( ) => {
1280+ const componentSet = {
1281+ type : 'COMPONENT_SET' ,
1282+ name : 'Label' ,
1283+ componentPropertyDefinitions : {
1284+ 'text#80:456' : {
1285+ type : 'TEXT' ,
1286+ defaultValue : 'Hello' ,
1287+ } ,
1288+ } ,
1289+ }
1290+ const node = {
1291+ type : 'COMPONENT' ,
1292+ name : 'default' ,
1293+ variantProperties : { } ,
1294+ parent : componentSet ,
1295+ } as unknown as SceneNode
1296+
1297+ const result = codeModule . generateComponentUsage ( node )
1298+ expect ( result ) . toBe ( '<Label>Hello</Label>' )
1299+ } )
1300+
1301+ it ( 'should use children syntax for COMPONENT_SET with BOOLEAN and single TEXT' , ( ) => {
1302+ const node = {
1303+ type : 'COMPONENT_SET' ,
1304+ name : 'Menu' ,
1305+ componentPropertyDefinitions : {
1306+ 'link#70:456' : {
1307+ type : 'BOOLEAN' ,
1308+ defaultValue : true ,
1309+ } ,
1310+ 'text#80:456' : {
1311+ type : 'TEXT' ,
1312+ defaultValue : '텍스트' ,
1313+ } ,
1314+ } ,
1315+ } as unknown as SceneNode
1316+
1317+ const result = codeModule . generateComponentUsage ( node )
1318+ expect ( result ) . toBe ( '<Menu link>텍스트</Menu>' )
1319+ } )
1320+
1321+ it ( 'should use children syntax for COMPONENT_SET with single TEXT-only prop (no other props)' , ( ) => {
1322+ const node = {
1323+ type : 'COMPONENT_SET' ,
1324+ name : 'Label' ,
1325+ componentPropertyDefinitions : {
1326+ 'text#80:456' : {
1327+ type : 'TEXT' ,
1328+ defaultValue : 'Hello' ,
1329+ } ,
1330+ } ,
1331+ } as unknown as SceneNode
1332+
1333+ const result = codeModule . generateComponentUsage ( node )
1334+ expect ( result ) . toBe ( '<Label>Hello</Label>' )
1335+ } )
1336+
1337+ it ( 'should keep prop syntax for COMPONENT_SET with 2+ TEXT properties' , ( ) => {
1338+ const node = {
1339+ type : 'COMPONENT_SET' ,
1340+ name : 'Card' ,
1341+ componentPropertyDefinitions : {
1342+ 'title#80:111' : {
1343+ type : 'TEXT' ,
1344+ defaultValue : 'Hello' ,
1345+ } ,
1346+ 'description#80:222' : {
1347+ type : 'TEXT' ,
1348+ defaultValue : 'World' ,
1349+ } ,
1350+ } ,
1351+ } as unknown as SceneNode
1352+
1353+ const result = codeModule . generateComponentUsage ( node )
1354+ expect ( result ) . toBe ( '<Card title="Hello" description="World" />' )
1355+ } )
1356+
1357+ it ( 'should keep prop syntax for COMPONENT with 2+ TEXT properties from parent' , ( ) => {
1358+ const componentSet = {
1359+ type : 'COMPONENT_SET' ,
1360+ name : 'Card' ,
1361+ componentPropertyDefinitions : {
1362+ 'title#80:111' : {
1363+ type : 'TEXT' ,
1364+ defaultValue : 'Hello' ,
1365+ } ,
1366+ 'description#80:222' : {
1367+ type : 'TEXT' ,
1368+ defaultValue : 'World' ,
1369+ } ,
1370+ } ,
1371+ }
1372+ const node = {
1373+ type : 'COMPONENT' ,
1374+ name : 'default' ,
1375+ variantProperties : { } ,
1376+ parent : componentSet ,
1377+ } as unknown as SceneNode
1378+
1379+ const result = codeModule . generateComponentUsage ( node )
1380+ expect ( result ) . toBe ( '<Card title="Hello" description="World" />' )
1381+ } )
1382+
1383+ it ( 'should skip INSTANCE_SWAP properties for COMPONENT_SET' , ( ) => {
1384+ const node = {
1385+ type : 'COMPONENT_SET' ,
1386+ name : 'MyButton' ,
1387+ componentPropertyDefinitions : {
1388+ icon : {
1389+ type : 'INSTANCE_SWAP' ,
1390+ defaultValue : 'some-id' ,
1391+ } ,
1392+ } ,
1393+ } as unknown as SceneNode
1394+
1395+ const result = codeModule . generateComponentUsage ( node )
1396+ expect ( result ) . toBe ( '<MyButton />' )
1397+ } )
1398+
11571399 it ( 'should generate usage for COMPONENT_SET without componentPropertyDefinitions' , ( ) => {
11581400 const node = {
11591401 type : 'COMPONENT_SET' ,
0 commit comments