@@ -1089,4 +1089,85 @@ describe("VueFormGenerator.vue", () => {
1089
1089
} ) ;
1090
1090
} ) ;
1091
1091
} ) ;
1092
+
1093
+ describe . only ( "check custom slot" , ( ) => {
1094
+ let schema = {
1095
+ fields : [
1096
+ {
1097
+ type : "input" ,
1098
+ fieldOptions : {
1099
+ inputType : "text" ,
1100
+ min : 3
1101
+ } ,
1102
+ label : "My label" ,
1103
+ help : "My help" ,
1104
+ hint : "My hint" ,
1105
+ model : "name" ,
1106
+ validator : [ "string" ]
1107
+ }
1108
+ ]
1109
+ } ;
1110
+ let model = { name : "B" } ;
1111
+ let formOptions = { validateAfterLoad : true } ;
1112
+ let formGenerator ;
1113
+ let form ;
1114
+
1115
+ beforeEach ( ( ) => {
1116
+ createFormGenerator (
1117
+ { schema, model, formOptions } ,
1118
+ { } ,
1119
+ `<vue-form-generator :schema="schema" ref="form" tag="section">
1120
+ <template slot="label" slot-scope="{ field, getValueFromOption }">
1121
+ <span class="custom-class--label">Custom label</span>
1122
+ <div v-html="getValueFromOption(field, 'label', undefined)"></div>
1123
+ </template>
1124
+
1125
+ <template slot="help" slot-scope="{ field, getValueFromOption }">
1126
+ <span class="custom-class--help">Custom help</span>
1127
+ <div v-html="getValueFromOption(field, 'help', undefined)"></div>
1128
+ </template>
1129
+
1130
+ <template slot="hint" slot-scope="{ field, getValueFromOption }">
1131
+ <span class="custom-class--hint">Custom hint</span>
1132
+ <div v-html="getValueFromOption(field, 'hint', undefined)"></div>
1133
+ </template>
1134
+
1135
+ <template slot="errors" slot-scope="{ errors, field, getValueFromOption }">
1136
+ <span class="custom-class--errors">Custom errors</span>
1137
+ <div v-for="(error, index) in errors" :key="index">
1138
+ {{index}}
1139
+ </div>
1140
+ </template>
1141
+ </vue-form-generator>`
1142
+ ) ;
1143
+ formGenerator = wrapper . find ( { name : "formGenerator" } ) ;
1144
+ form = formGenerator . vm ;
1145
+ } ) ;
1146
+
1147
+ it ( "should have a custom label" , ( ) => {
1148
+ expect ( formGenerator . find ( ".custom-class--label" ) . exists ( ) ) . to . be . true ;
1149
+ } ) ;
1150
+
1151
+ it ( "should have a custom help" , ( ) => {
1152
+ expect ( formGenerator . find ( ".custom-class--help" ) . exists ( ) ) . to . be . true ;
1153
+ } ) ;
1154
+
1155
+ it ( "should have a custom hint" , ( ) => {
1156
+ expect ( formGenerator . find ( ".custom-class--hint" ) . exists ( ) ) . to . be . true ;
1157
+ } ) ;
1158
+ // TODO: fix error not showing
1159
+ it . skip ( "should have a custom error" , ( done ) => {
1160
+ Vue . config . errorHandler = done ;
1161
+
1162
+ form . validate ( ) . then (
1163
+ ( ) => {
1164
+ Vue . nextTick ( ( ) => {
1165
+ expect ( formGenerator . find ( ".custom-class--errors" ) . exists ( ) ) . to . be . true ;
1166
+ done ( ) ;
1167
+ } ) ;
1168
+ } ,
1169
+ ( ) => { }
1170
+ ) ;
1171
+ } ) ;
1172
+ } ) ;
1092
1173
} ) ;
0 commit comments