@@ -42,12 +42,14 @@ describe('base-commands', () => {
42
42
envEdge,
43
43
configRegion = 'configRegion' ,
44
44
configEdge,
45
+ configRequireProfileInput,
45
46
} = { } ,
46
47
) => {
47
48
return test
48
49
. do ( ( ctx ) => {
49
50
ctx . userConfig = new ConfigData ( ) ;
50
51
ctx . userConfig . edge = configEdge ;
52
+ ctx . userConfig . requireProfileInput = configRequireProfileInput ;
51
53
52
54
if ( envRegion ) {
53
55
process . env . TWILIO_REGION = envRegion ;
@@ -89,6 +91,27 @@ describe('base-commands', () => {
89
91
} ) ;
90
92
} ;
91
93
94
+ setUpTest ( [ ] , { configRequireProfileInput : true } )
95
+ . exit ( 1 )
96
+ . it ( 'should fail if requireProfileInput attribute in config is set but flag is not passed' , ( ctx ) => {
97
+ expect ( ctx . stderr ) . to . contain ( 'Error: Missing required flag:' ) ;
98
+ expect ( ctx . stderr ) . to . contain ( '-p, --profile PROFILE' ) ;
99
+ } ) ;
100
+
101
+ setUpTest ( [ '-p' , '' ] , { configRequireProfileInput : true } )
102
+ . exit ( 1 )
103
+ . it ( 'should fail if requireProfileInput attribute in config is set but flag is passed as empty string' , ( ctx ) => {
104
+ expect ( ctx . stderr ) . to . contain ( 'Error: Missing required flag:' ) ;
105
+ expect ( ctx . stderr ) . to . contain ( '-p, --profile PROFILE' ) ;
106
+ } ) ;
107
+
108
+ setUpTest ( [ '-p' , 'region-edge-testing' ] , { configRequireProfileInput : true } ) . it (
109
+ 'should use the profile passed, when requireProfileInput flag is set in config and valid profile is passed' ,
110
+ ( ctx ) => {
111
+ expect ( ctx . testCmd . currentProfile . id ) . to . equal ( 'region-edge-testing' ) ;
112
+ } ,
113
+ ) ;
114
+
92
115
setUpTest ( [ '-l' , 'debug' ] ) . it ( 'should create a client for the active profile' , ( ctx ) => {
93
116
expect ( ctx . stderr ) . to . contain ( 'MyFirstProfile' ) ;
94
117
expect ( ctx . testCmd . twilioClient . accountSid ) . to . equal ( constants . FAKE_ACCOUNT_SID ) ;
0 commit comments