@@ -1178,3 +1178,135 @@ describe("className visitor - custom color scheme hook", () => {
11781178 expect ( output ) . not . toContain ( "_twColorScheme = useTheme()" ) ;
11791179 } ) ;
11801180} ) ;
1181+
1182+ describe ( "className visitor - directional border colors" , ( ) => {
1183+ it ( "should transform directional border colors with preset values" , ( ) => {
1184+ const input = `
1185+ import { View } from 'react-native';
1186+ export function Component() {
1187+ return <View className="border-t-red-500 border-l-blue-500" />;
1188+ }
1189+ ` ;
1190+
1191+ const output = transform ( input , undefined , true ) ;
1192+
1193+ // Should have StyleSheet
1194+ expect ( output ) . toContain ( "StyleSheet.create" ) ;
1195+
1196+ // Should generate styles with borderTopColor and borderLeftColor
1197+ expect ( output ) . toMatch ( / b o r d e r T o p C o l o r [: \s] * [ ' " ] # [ 0 - 9 A - F ] { 6 } [ ' " ] / i) ;
1198+ expect ( output ) . toMatch ( / b o r d e r L e f t C o l o r [: \s] * [ ' " ] # [ 0 - 9 A - F ] { 6 } [ ' " ] / i) ;
1199+
1200+ // Should not have className in output
1201+ expect ( output ) . not . toContain ( "className" ) ;
1202+ } ) ;
1203+
1204+ it ( "should combine directional border width and color" , ( ) => {
1205+ const input = `
1206+ import { View } from 'react-native';
1207+ export function Component() {
1208+ return <View className="border-l-2 border-l-red-500" />;
1209+ }
1210+ ` ;
1211+
1212+ const output = transform ( input , undefined , true ) ;
1213+
1214+ // Should have both borderLeftWidth and borderLeftColor in the StyleSheet
1215+ expect ( output ) . toMatch ( / b o r d e r L e f t W i d t h [: \s] * 2 / ) ;
1216+ expect ( output ) . toMatch ( / b o r d e r L e f t C o l o r [: \s] * [ ' " ] # [ 0 - 9 A - F ] { 6 } [ ' " ] / i) ;
1217+
1218+ // Should not have className in output
1219+ expect ( output ) . not . toContain ( "className" ) ;
1220+ } ) ;
1221+
1222+ it ( "should support directional border colors with opacity" , ( ) => {
1223+ const input = `
1224+ import { View } from 'react-native';
1225+ export function Component() {
1226+ return <View className="border-t-red-500/50 border-b-blue-500/80" />;
1227+ }
1228+ ` ;
1229+
1230+ const output = transform ( input , undefined , true ) ;
1231+
1232+ // Should have 8-digit hex colors with alpha channel
1233+ expect ( output ) . toMatch ( / b o r d e r T o p C o l o r [: \s] * [ ' " ] # [ 0 - 9 A - F ] { 8 } [ ' " ] / i) ;
1234+ expect ( output ) . toMatch ( / b o r d e r B o t t o m C o l o r [: \s] * [ ' " ] # [ 0 - 9 A - F ] { 8 } [ ' " ] / i) ;
1235+ } ) ;
1236+
1237+ it ( "should support directional border colors with arbitrary hex values" , ( ) => {
1238+ const input = `
1239+ import { View } from 'react-native';
1240+ export function Component() {
1241+ return <View className="border-t-[#ff0000] border-r-[#abc]" />;
1242+ }
1243+ ` ;
1244+
1245+ const output = transform ( input , undefined , true ) ;
1246+
1247+ // Should have borderTopColor and borderRightColor
1248+ expect ( output ) . toMatch ( / b o r d e r T o p C o l o r [: \s] * [ ' " ] # [ 0 - 9 a - f A - F ] { 6 } [ ' " ] / ) ;
1249+ expect ( output ) . toMatch ( / b o r d e r R i g h t C o l o r [: \s] * [ ' " ] # [ 0 - 9 a - f A - F ] { 6 } [ ' " ] / ) ;
1250+ } ) ;
1251+
1252+ it ( "should support all four directional border colors" , ( ) => {
1253+ const input = `
1254+ import { View } from 'react-native';
1255+ export function Component() {
1256+ return (
1257+ <View className="border-t-red-500 border-r-blue-500 border-b-green-500 border-l-yellow-500" />
1258+ );
1259+ }
1260+ ` ;
1261+
1262+ const output = transform ( input , undefined , true ) ;
1263+
1264+ // Should have all four directional color properties
1265+ expect ( output ) . toMatch ( / b o r d e r T o p C o l o r [: \s] * [ ' " ] # [ 0 - 9 A - F ] { 6 } [ ' " ] / i) ;
1266+ expect ( output ) . toMatch ( / b o r d e r R i g h t C o l o r [: \s] * [ ' " ] # [ 0 - 9 A - F ] { 6 } [ ' " ] / i) ;
1267+ expect ( output ) . toMatch ( / b o r d e r B o t t o m C o l o r [: \s] * [ ' " ] # [ 0 - 9 A - F ] { 6 } [ ' " ] / i) ;
1268+ expect ( output ) . toMatch ( / b o r d e r L e f t C o l o r [: \s] * [ ' " ] # [ 0 - 9 A - F ] { 6 } [ ' " ] / i) ;
1269+ } ) ;
1270+
1271+ it ( "should combine directional widths, colors, and general border color" , ( ) => {
1272+ const input = `
1273+ import { View } from 'react-native';
1274+ export function Component() {
1275+ return (
1276+ <View className="border border-gray-300 border-l-4 border-l-blue-500" />
1277+ );
1278+ }
1279+ ` ;
1280+
1281+ const output = transform ( input , undefined , true ) ;
1282+
1283+ // Should have general border properties
1284+ expect ( output ) . toMatch ( / b o r d e r W i d t h [: \s] * 1 / ) ;
1285+ expect ( output ) . toMatch ( / b o r d e r C o l o r [: \s] * [ ' " ] # [ 0 - 9 A - F ] { 6 } [ ' " ] / i) ;
1286+
1287+ // Should have directional left border properties
1288+ expect ( output ) . toMatch ( / b o r d e r L e f t W i d t h [: \s] * 4 / ) ;
1289+ expect ( output ) . toMatch ( / b o r d e r L e f t C o l o r [: \s] * [ ' " ] # [ 0 - 9 A - F ] { 6 } [ ' " ] / i) ;
1290+ } ) ;
1291+
1292+ it ( "should work with dynamic className containing directional border colors" , ( ) => {
1293+ const input = `
1294+ import { View } from 'react-native';
1295+ export function Component({ isError }) {
1296+ return (
1297+ <View className={\`border-t-2 \${isError ? 'border-t-red-500' : 'border-t-gray-300'}\`} />
1298+ );
1299+ }
1300+ ` ;
1301+
1302+ const output = transform ( input , undefined , true ) ;
1303+
1304+ // Should have StyleSheet with both color options
1305+ expect ( output ) . toContain ( "_border_t_2" ) ;
1306+ expect ( output ) . toContain ( "_border_t_red_500" ) ;
1307+ expect ( output ) . toContain ( "_border_t_gray_300" ) ;
1308+
1309+ // Should have conditional expression with both styles
1310+ expect ( output ) . toMatch ( / i s E r r o r \s * \? \s * _ t w S t y l e s \. _ b o r d e r _ t _ r e d _ 5 0 0 / ) ;
1311+ } ) ;
1312+ } ) ;
0 commit comments