File tree 2 files changed +41
-1
lines changed
2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -319,7 +319,7 @@ module.exports = {
319
319
type : "textArea" ,
320
320
label : "Biography (textArea field)" ,
321
321
model : "bio" ,
322
- hint : function ( model ) {
322
+ hint ( model ) {
323
323
if ( model && model . bio ) {
324
324
return model . bio . length + " of max 500 characters used!" ;
325
325
}
Original file line number Diff line number Diff line change @@ -440,6 +440,46 @@ describe("VueFormGenerator.vue", () => {
440
440
441
441
} ) ;
442
442
443
+ describe ( "check fieldHint with function" , ( ) => {
444
+ let schema = {
445
+ fields : [
446
+ {
447
+ type : "textArea" ,
448
+ label : "Note" ,
449
+ model : "note" ,
450
+ max : 500 ,
451
+ rows : 4 ,
452
+ hint ( model ) {
453
+ if ( model && model . note ) {
454
+ return model . note . length + " of max 500 characters used!" ;
455
+ }
456
+ }
457
+ }
458
+ ]
459
+ } ;
460
+
461
+ let model = {
462
+ note : "John Doe"
463
+ } ;
464
+
465
+ before ( ( ) => {
466
+ createFormGenerator ( schema , model ) ;
467
+ } ) ;
468
+
469
+ it ( "should be applay" , ( ) => {
470
+ expect ( el . querySelector ( ".form-group .hint" ) . textContent ) . to . be . equal ( "8 of max 500 characters used!" ) ;
471
+ } ) ;
472
+
473
+ it ( "should be changed" , ( done ) => {
474
+ model . note = "Dr. John Doe" ;
475
+ vm . $nextTick ( ( ) => {
476
+ expect ( el . querySelector ( ".form-group .hint" ) . textContent ) . to . be . equal ( "12 of max 500 characters used!" ) ;
477
+ done ( ) ;
478
+ } ) ;
479
+ } ) ;
480
+
481
+ } ) ;
482
+
443
483
describe ( "check fieldFeatured with function" , ( ) => {
444
484
let schema = {
445
485
fields : [
You can’t perform that action at this time.
0 commit comments