File tree Expand file tree Collapse file tree 2 files changed +41
-1
lines changed
Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -319,7 +319,7 @@ module.exports = {
319319 type : "textArea" ,
320320 label : "Biography (textArea field)" ,
321321 model : "bio" ,
322- hint : function ( model ) {
322+ hint ( model ) {
323323 if ( model && model . bio ) {
324324 return model . bio . length + " of max 500 characters used!" ;
325325 }
Original file line number Diff line number Diff line change @@ -440,6 +440,46 @@ describe("VueFormGenerator.vue", () => {
440440
441441 } ) ;
442442
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+
443483 describe ( "check fieldFeatured with function" , ( ) => {
444484 let schema = {
445485 fields : [
You can’t perform that action at this time.
0 commit comments