@@ -1038,6 +1038,97 @@ test.group('Object node', () => {
1038
1038
data . profile = { }
1039
1039
assert . deepEqual ( output , { } )
1040
1040
} )
1041
+
1042
+ test ( 'get nested runtime field path' , async ( { assert } ) => {
1043
+ const compiler = new Compiler ( {
1044
+ type : 'root' ,
1045
+ schema : {
1046
+ type : 'object' ,
1047
+ groups : [ ] ,
1048
+ bail : true ,
1049
+ fieldName : '*' ,
1050
+ validations : [ ] ,
1051
+ propertyName : '*' ,
1052
+ allowNull : false ,
1053
+ isOptional : false ,
1054
+ allowUnknownProperties : false ,
1055
+ properties : [
1056
+ {
1057
+ type : 'object' ,
1058
+ groups : [ ] ,
1059
+ bail : true ,
1060
+ fieldName : 'social' ,
1061
+ validations : [ ] ,
1062
+ propertyName : 'social' ,
1063
+ allowNull : false ,
1064
+ isOptional : false ,
1065
+ allowUnknownProperties : false ,
1066
+ properties : [
1067
+ {
1068
+ type : 'literal' ,
1069
+ bail : true ,
1070
+ fieldName : 'twitter_handle' ,
1071
+ allowNull : false ,
1072
+ isOptional : false ,
1073
+ propertyName : 'twitterHandle' ,
1074
+ validations : [ ] ,
1075
+ transformFnId : 'ref://1' ,
1076
+ } ,
1077
+ {
1078
+ type : 'literal' ,
1079
+ bail : true ,
1080
+ fieldName : 'github_username' ,
1081
+ allowNull : false ,
1082
+ isOptional : false ,
1083
+ propertyName : 'githubUsername' ,
1084
+ validations : [ ] ,
1085
+ transformFnId : 'ref://2' ,
1086
+ } ,
1087
+ ] ,
1088
+ } ,
1089
+ ] ,
1090
+ } ,
1091
+ } )
1092
+
1093
+ const data = {
1094
+ social : {
1095
+ github_username : 'thetutlage' ,
1096
+ twitter_handle : 'AmanVirk1' ,
1097
+ } ,
1098
+ }
1099
+
1100
+ const refs = refsBuilder ( )
1101
+ refs . trackTransformer ( ( value , ctx ) => {
1102
+ assert . equal ( ctx . getFieldPath ( ) , 'social.twitter_handle' )
1103
+ return value
1104
+ } )
1105
+ refs . trackTransformer ( ( value , ctx ) => {
1106
+ assert . equal ( ctx . getFieldPath ( ) , 'social.github_username' )
1107
+ return value
1108
+ } )
1109
+
1110
+ const meta = { }
1111
+ const messagesProvider = new MessagesProviderFactory ( ) . create ( )
1112
+ const errorReporter = new ErrorReporterFactory ( ) . create ( )
1113
+
1114
+ const fn = compiler . compile ( )
1115
+ const output = await fn ( data , meta , refs . toJSON ( ) , messagesProvider , errorReporter )
1116
+ assert . deepEqual ( output , {
1117
+ social : {
1118
+ githubUsername : 'thetutlage' ,
1119
+ twitterHandle : 'AmanVirk1' ,
1120
+ } ,
1121
+ } )
1122
+
1123
+ // Mutation test:
1124
+ data . social . github_username = 'foo'
1125
+ assert . deepEqual ( output , {
1126
+ social : {
1127
+ githubUsername : 'thetutlage' ,
1128
+ twitterHandle : 'AmanVirk1' ,
1129
+ } ,
1130
+ } )
1131
+ } )
1041
1132
} )
1042
1133
1043
1134
test . group ( 'Object node | optional: true' , ( ) => {
0 commit comments