1
1
"use strict" ;
2
2
import * as utils from "../index" ;
3
3
4
- describe . skip ( "utils" , ( ) => {
4
+ describe ( "utils" , ( ) => {
5
+ beforeEach ( ( ) => {
6
+ this . mockSelf = {
7
+ prompt : arg => {
8
+ return arg [ 0 ] ;
9
+ }
10
+ } ;
11
+ } ) ;
5
12
describe ( "createArrowFunction" , ( ) => {
6
13
it ( "should stringify an arrow function" , ( ) => {
7
14
expect ( utils . createArrowFunction ( "app.js" ) ) . toMatchSnapshot ( ) ;
@@ -44,12 +51,9 @@ describe.skip("utils", () => {
44
51
} ) ;
45
52
} ) ;
46
53
describe ( "Inquirer" , ( ) => {
47
- it ( "should make a List object" , ( ) => {
48
- expect ( utils . List ( "entry" , "does it work?" , [ "Yes" , "Maybe" ] ) ) . toEqual ( {
49
- choices : [ "Yes" , "Maybe" ] ,
50
- message : "does it work?" ,
51
- name : "entry" ,
52
- type : "list"
54
+ it ( "should make default value for a List" , ( ) => {
55
+ expect ( utils . List ( this . mockSelf , "entry" , "does it work?" , [ "Yes" , "Maybe" ] , "Yes" , true ) ) . toEqual ( {
56
+ entry : "Yes"
53
57
} ) ;
54
58
} ) ;
55
59
it ( "should make a RawList object" , ( ) => {
@@ -68,42 +72,39 @@ describe.skip("utils", () => {
68
72
type : "checkbox"
69
73
} ) ;
70
74
} ) ;
71
- it ( "should make an Input object " , ( ) => {
72
- expect ( utils . Input ( "plugins" , "what is your plugin?" ) ) . toEqual ( {
73
- message : "what is your plugin? " ,
75
+ it ( "should emulate a prompt for list input " , ( ) => {
76
+ expect ( utils . Input ( this . mockSelf , "plugins" , "what is your plugin?" , "openJSF" , false ) ) . toEqual ( {
77
+ type : "input " ,
74
78
name : "plugins" ,
75
- type : "input"
79
+ message : "what is your plugin?" ,
80
+ default : "openJSF"
76
81
} ) ;
77
82
} ) ;
78
- it ( "should make an Input object" , ( ) => {
79
- expect ( utils . Input ( "plugins" , "what is your plugin?" , "my-plugin" ) ) . toEqual ( {
80
- default : "my-plugin" ,
81
- message : "what is your plugin?" ,
82
- name : "plugins" ,
83
- type : "input"
83
+ it ( "should return a default Input object value" , ( ) => {
84
+ expect ( utils . Input ( this . mockSelf , "plugins" , "what is your plugin?" , "my-plugin" , true ) ) . toEqual ( {
85
+ plugins : "my-plugin"
84
86
} ) ;
85
87
} ) ;
86
- it ( "should make a Confirm object" , ( ) => {
87
- expect ( utils . Confirm ( "context" , "what is your context?" ) ) . toEqual ( {
88
+ it ( "should emulate a prompt for confirm" , ( ) => {
89
+ expect ( utils . Confirm ( this . mockSelf , "context" , "what is your context?" , true , false ) ) . toEqual ( {
90
+ name : "context" ,
88
91
default : true ,
89
92
message : "what is your context?" ,
90
- name : "context" ,
91
93
type : "confirm"
92
94
} ) ;
93
95
} ) ;
94
- it ( "should make a Confirm object with No as default" , ( ) => {
95
- expect ( utils . Confirm ( "context" , "what is your context?" , false ) ) . toEqual ( {
96
- default : false ,
97
- message : "what is your context?" ,
98
- name : "context" ,
99
- type : "confirm"
96
+ it ( "should make a Confirm object with yes as default" , ( ) => {
97
+ expect ( utils . Confirm ( this . mockSelf , "context" , "what is your context?" , true , true ) ) . toEqual ( {
98
+ context : true
100
99
} ) ;
101
100
} ) ;
102
101
it ( "should make an Input object with validation" , ( ) => {
103
- expect ( utils . InputValidate ( "plugins" , "what is your plugin?" , ( ) => true ) ) . toMatchSnapshot ( ) ;
102
+ expect ( utils . InputValidate ( this . mockSelf , "plugins" , "what is your plugin?" , ( ) => true ) ) . toMatchSnapshot ( ) ;
104
103
} ) ;
105
104
it ( "should make an Input object with validation and default value" , ( ) => {
106
- expect ( utils . InputValidate ( "plugins" , "what is your plugin?" , ( ) => true , "my-plugin" ) ) . toMatchSnapshot ( ) ;
105
+ expect (
106
+ utils . InputValidate ( this . mockSelf , "plugins" , "what is your plugin?" , ( ) => true , "my-plugin" )
107
+ ) . toMatchSnapshot ( ) ;
107
108
} ) ;
108
109
} ) ;
109
110
} ) ;
0 commit comments