File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,8 @@ const questions = (config) => {
3333 name : 'scope' ,
3434 message : 'Enter your scope (no whitespaces allowed):' ,
3535 when : ( ) => config . questions . scope ,
36- filter : answers => ( answers ? `(${ answers } )` : answers ) ,
36+ validate : input => ( input . match ( / \s / ) !== null ? 'No whitespaces allowed' : true ) ,
37+ filter : input => ( input ? `(${ input } )` : input ) ,
3738 } ,
3839 {
3940 type : 'input' ,
Original file line number Diff line number Diff line change @@ -92,14 +92,22 @@ test('check if scope is off by default', (t) => {
9292 t . is ( questionsList [ 1 ] . when ( ) , false ) ;
9393} ) ;
9494
95- test ( 'check if scope validates correctly' , ( t ) => {
95+ test ( 'check if scope filters correctly' , ( t ) => {
9696 const config = getConfig ( ) ;
9797 const questionsList = questions ( config ) ;
9898
9999 t . is ( questionsList [ 1 ] . filter ( 'answer' ) , '(answer)' ) ;
100100 t . is ( questionsList [ 1 ] . filter ( '' ) , '' ) ;
101101} ) ;
102102
103+ test ( 'check if scope validates correctly' , ( t ) => {
104+ const config = getConfig ( ) ;
105+ const questionsList = questions ( config ) ;
106+
107+ t . is ( questionsList [ 1 ] . validate ( 'not correct' ) , 'No whitespaces allowed' ) ;
108+ t . is ( questionsList [ 1 ] . validate ( 'correct' ) , true ) ;
109+ } ) ;
110+
103111test ( 'validate functions in questions' , ( t ) => {
104112 const config = getConfig ( ) ;
105113 const questionsList = questions ( config ) ;
You can’t perform that action at this time.
0 commit comments