@@ -21,7 +21,7 @@ describe('SlackCLIProcess class', () => {
2121 const orig = process . env . SLACK_CLI_PATH ;
2222 process . env . SLACK_CLI_PATH = '' ;
2323 assert . throws ( ( ) => {
24- new SlackCLIProcess ( 'help' ) ;
24+ new SlackCLIProcess ( [ 'help' ] ) ;
2525 } ) ;
2626 process . env . SLACK_CLI_PATH = orig ;
2727 } ) ;
@@ -30,108 +30,156 @@ describe('SlackCLIProcess class', () => {
3030 describe ( 'CLI flag handling' , ( ) => {
3131 describe ( 'global options' , ( ) => {
3232 it ( 'should map dev option to --slackdev' , async ( ) => {
33- let cmd = new SlackCLIProcess ( 'help' , { dev : true } ) ;
33+ let cmd = new SlackCLIProcess ( [ 'help' ] , { dev : true } ) ;
3434 await cmd . execAsync ( ) ;
35- sandbox . assert . calledWithMatch ( spawnProcessSpy , '--slackdev' ) ;
35+ sandbox . assert . calledWith ( spawnProcessSpy , sinon . match . string , sinon . match . array . contains ( [ '--slackdev' ] ) ) ;
3636 spawnProcessSpy . resetHistory ( ) ;
37- cmd = new SlackCLIProcess ( 'help' ) ;
37+ cmd = new SlackCLIProcess ( [ 'help' ] ) ;
3838 await cmd . execAsync ( ) ;
39- sandbox . assert . neverCalledWithMatch ( spawnProcessSpy , '--slackdev' ) ;
39+ sandbox . assert . neverCalledWith ( spawnProcessSpy , sinon . match . string , sinon . match . array . contains ( [ '--slackdev' ] ) ) ;
4040 spawnProcessSpy . resetHistory ( ) ;
4141 } ) ;
4242 it ( 'should map qa option to QA host' , async ( ) => {
43- let cmd = new SlackCLIProcess ( 'help' , { qa : true } ) ;
43+ let cmd = new SlackCLIProcess ( [ 'help' ] , { qa : true } ) ;
4444 await cmd . execAsync ( ) ;
45- sandbox . assert . calledWithMatch ( spawnProcessSpy , '--apihost qa.slack.com' ) ;
45+ sandbox . assert . calledWith (
46+ spawnProcessSpy ,
47+ sinon . match . string ,
48+ sinon . match . array . contains ( [ '--apihost' , 'qa.slack.com' ] ) ,
49+ ) ;
4650 spawnProcessSpy . resetHistory ( ) ;
47- cmd = new SlackCLIProcess ( 'help' ) ;
51+ cmd = new SlackCLIProcess ( [ 'help' ] ) ;
4852 await cmd . execAsync ( ) ;
49- sandbox . assert . neverCalledWithMatch ( spawnProcessSpy , '--apihost qa.slack.com' ) ;
53+ sandbox . assert . neverCalledWith (
54+ spawnProcessSpy ,
55+ sinon . match . string ,
56+ sinon . match . array . contains ( [ '--apihost' , 'qa.slack.com' ] ) ,
57+ ) ;
5058 spawnProcessSpy . resetHistory ( ) ;
5159 } ) ;
5260 it ( 'should map apihost option to provided host' , async ( ) => {
53- let cmd = new SlackCLIProcess ( 'help' , { apihost : 'dev123.slack.com' } ) ;
61+ let cmd = new SlackCLIProcess ( [ 'help' ] , { apihost : 'dev123.slack.com' } ) ;
5462 await cmd . execAsync ( ) ;
55- sandbox . assert . calledWithMatch ( spawnProcessSpy , '--apihost dev123.slack.com' ) ;
63+ sandbox . assert . calledWith (
64+ spawnProcessSpy ,
65+ sinon . match . string ,
66+ sinon . match . array . contains ( [ '--apihost' , 'dev123.slack.com' ] ) ,
67+ ) ;
5668 spawnProcessSpy . resetHistory ( ) ;
57- cmd = new SlackCLIProcess ( 'help' ) ;
69+ cmd = new SlackCLIProcess ( [ 'help' ] ) ;
5870 await cmd . execAsync ( ) ;
59- sandbox . assert . neverCalledWithMatch ( spawnProcessSpy , '--apihost dev123.slack.com' ) ;
71+ sandbox . assert . neverCalledWith (
72+ spawnProcessSpy ,
73+ sinon . match . string ,
74+ sinon . match . array . contains ( [ '--apihost' , 'dev123.slack.com' ] ) ,
75+ ) ;
6076 spawnProcessSpy . resetHistory ( ) ;
6177 } ) ;
6278 it ( 'should default to passing --skip-update but allow overriding that' , async ( ) => {
63- let cmd = new SlackCLIProcess ( 'help' ) ;
79+ let cmd = new SlackCLIProcess ( [ 'help' ] ) ;
6480 await cmd . execAsync ( ) ;
65- sandbox . assert . calledWithMatch ( spawnProcessSpy , '--skip-update' ) ;
81+ sandbox . assert . calledWith ( spawnProcessSpy , sinon . match . string , sinon . match . array . contains ( [ '--skip-update' ] ) ) ;
6682 spawnProcessSpy . resetHistory ( ) ;
67- cmd = new SlackCLIProcess ( 'help' , { skipUpdate : false } ) ;
83+ cmd = new SlackCLIProcess ( [ 'help' ] , { skipUpdate : false } ) ;
6884 await cmd . execAsync ( ) ;
69- sandbox . assert . neverCalledWithMatch ( spawnProcessSpy , '--skip-update' ) ;
85+ sandbox . assert . neverCalledWith (
86+ spawnProcessSpy ,
87+ sinon . match . string ,
88+ sinon . match . array . contains ( [ '--skip-update' ] ) ,
89+ ) ;
7090 spawnProcessSpy . resetHistory ( ) ;
71- cmd = new SlackCLIProcess ( 'help' , { skipUpdate : true } ) ;
91+ cmd = new SlackCLIProcess ( [ 'help' ] , { skipUpdate : true } ) ;
7292 await cmd . execAsync ( ) ;
73- sandbox . assert . calledWithMatch ( spawnProcessSpy , '--skip-update' ) ;
93+ sandbox . assert . calledWith ( spawnProcessSpy , sinon . match . string , sinon . match . array . contains ( [ '--skip-update' ] ) ) ;
7494 spawnProcessSpy . resetHistory ( ) ;
75- cmd = new SlackCLIProcess ( 'help' , { } ) ; // empty global options; so undefined skipUpdate option
95+ cmd = new SlackCLIProcess ( [ 'help' ] , { } ) ; // empty global options; so undefined skipUpdate option
7696 await cmd . execAsync ( ) ;
77- sandbox . assert . calledWithMatch ( spawnProcessSpy , '--skip-update' ) ;
97+ sandbox . assert . calledWith ( spawnProcessSpy , sinon . match . string , sinon . match . array . contains ( [ '--skip-update' ] ) ) ;
7898 } ) ;
7999 it ( 'should default to `--app deployed` but allow overriding that via the `app` parameter' , async ( ) => {
80- let cmd = new SlackCLIProcess ( 'help' ) ;
100+ let cmd = new SlackCLIProcess ( [ 'help' ] ) ;
81101 await cmd . execAsync ( ) ;
82- sandbox . assert . calledWithMatch ( spawnProcessSpy , '--app deployed' ) ;
102+ sandbox . assert . calledWith (
103+ spawnProcessSpy ,
104+ sinon . match . string ,
105+ sinon . match . array . contains ( [ '--app' , 'deployed' ] ) ,
106+ ) ;
83107 spawnProcessSpy . resetHistory ( ) ;
84- cmd = new SlackCLIProcess ( 'help' , { app : 'local' } ) ;
108+ cmd = new SlackCLIProcess ( [ 'help' ] , { app : 'local' } ) ;
85109 await cmd . execAsync ( ) ;
86- sandbox . assert . calledWithMatch ( spawnProcessSpy , '--app local' ) ;
110+ sandbox . assert . calledWith ( spawnProcessSpy , sinon . match . string , sinon . match . array . contains ( [ '--app' , ' local'] ) ) ;
87111 } ) ;
88112 it ( 'should default to `--force` but allow overriding that via the `force` parameter' , async ( ) => {
89- let cmd = new SlackCLIProcess ( 'help' ) ;
113+ let cmd = new SlackCLIProcess ( [ 'help' ] ) ;
90114 await cmd . execAsync ( ) ;
91- sandbox . assert . calledWithMatch ( spawnProcessSpy , '--force' ) ;
115+ sandbox . assert . calledWith ( spawnProcessSpy , sinon . match . string , sinon . match . array . contains ( [ '--force' ] ) ) ;
92116 spawnProcessSpy . resetHistory ( ) ;
93- cmd = new SlackCLIProcess ( 'help' , { force : true } ) ;
117+ cmd = new SlackCLIProcess ( [ 'help' ] , { force : true } ) ;
94118 await cmd . execAsync ( ) ;
95- sandbox . assert . calledWithMatch ( spawnProcessSpy , '--force' ) ;
119+ sandbox . assert . calledWithMatch ( spawnProcessSpy , sinon . match . string , sinon . match . array . contains ( [ '--force' ] ) ) ;
96120 spawnProcessSpy . resetHistory ( ) ;
97- cmd = new SlackCLIProcess ( 'help' , { force : false } ) ;
121+ cmd = new SlackCLIProcess ( [ 'help' ] , { force : false } ) ;
98122 await cmd . execAsync ( ) ;
99- sandbox . assert . neverCalledWithMatch ( spawnProcessSpy , '--force' ) ;
123+ sandbox . assert . neverCalledWith ( spawnProcessSpy , sinon . match . string , sinon . match . array . contains ( [ '--force' ] ) ) ;
100124 } ) ;
101125 it ( 'should map token option to `--token`' , async ( ) => {
102- let cmd = new SlackCLIProcess ( 'help' , { token : 'xoxb-1234' } ) ;
126+ let cmd = new SlackCLIProcess ( [ 'help' ] , { token : 'xoxb-1234' } ) ;
103127 await cmd . execAsync ( ) ;
104- sandbox . assert . calledWithMatch ( spawnProcessSpy , '--token xoxb-1234' ) ;
128+ sandbox . assert . calledWith (
129+ spawnProcessSpy ,
130+ sinon . match . string ,
131+ sinon . match . array . contains ( [ '--token' , 'xoxb-1234' ] ) ,
132+ ) ;
105133 spawnProcessSpy . resetHistory ( ) ;
106- cmd = new SlackCLIProcess ( 'help' ) ;
134+ cmd = new SlackCLIProcess ( [ 'help' ] ) ;
107135 await cmd . execAsync ( ) ;
108- sandbox . assert . neverCalledWithMatch ( spawnProcessSpy , '--token xoxb-1234' ) ;
136+ sandbox . assert . neverCalledWith (
137+ spawnProcessSpy ,
138+ sinon . match . string ,
139+ sinon . match . array . contains ( [ '--token' , 'xoxb-1234' ] ) ,
140+ ) ;
109141 spawnProcessSpy . resetHistory ( ) ;
110142 } ) ;
111143 } ) ;
112144 describe ( 'command options' , ( ) => {
113145 it ( 'should pass command-level key/value options to command in the form `--<key> value`' , async ( ) => {
114- const cmd = new SlackCLIProcess ( 'help' , { } , { '--awesome' : 'yes' } ) ;
146+ const cmd = new SlackCLIProcess ( [ 'help' ] , { } , { '--awesome' : 'yes' } ) ;
115147 await cmd . execAsync ( ) ;
116- sandbox . assert . calledWithMatch ( spawnProcessSpy , '--awesome yes' ) ;
148+ sandbox . assert . calledWith (
149+ spawnProcessSpy ,
150+ sinon . match . string ,
151+ sinon . match . array . contains ( [ '--awesome' , 'yes' ] ) ,
152+ ) ;
117153 } ) ;
118154 it ( 'should only pass command-level key option if value is true in the form `--key`' , async ( ) => {
119- const cmd = new SlackCLIProcess ( 'help' , { } , { '--no-prompt' : true } ) ;
155+ const cmd = new SlackCLIProcess ( [ 'help' ] , { } , { '--no-prompt' : true } ) ;
120156 await cmd . execAsync ( ) ;
121- sandbox . assert . calledWithMatch ( spawnProcessSpy , '--no-prompt' ) ;
157+ sandbox . assert . calledWith ( spawnProcessSpy , sinon . match . string , sinon . match . array . contains ( [ '--no-prompt' ] ) ) ;
122158 } ) ;
123159 it ( 'should not pass command-level key option if value is falsy' , async ( ) => {
124- let cmd = new SlackCLIProcess ( 'help' , { } , { '--no-prompt' : false } ) ;
160+ let cmd = new SlackCLIProcess ( [ 'help' ] , { } , { '--no-prompt' : false } ) ;
125161 await cmd . execAsync ( ) ;
126- sandbox . assert . neverCalledWithMatch ( spawnProcessSpy , '--no-prompt' ) ;
162+ sandbox . assert . neverCalledWith (
163+ spawnProcessSpy ,
164+ sinon . match . string ,
165+ sinon . match . array . contains ( [ '--no-prompt' ] ) ,
166+ ) ;
127167 spawnProcessSpy . resetHistory ( ) ;
128- cmd = new SlackCLIProcess ( 'help' , { } , { '--no-prompt' : '' } ) ;
168+ cmd = new SlackCLIProcess ( [ 'help' ] , { } , { '--no-prompt' : '' } ) ;
129169 await cmd . execAsync ( ) ;
130- sandbox . assert . neverCalledWithMatch ( spawnProcessSpy , '--no-prompt' ) ;
170+ sandbox . assert . neverCalledWith (
171+ spawnProcessSpy ,
172+ sinon . match . string ,
173+ sinon . match . array . contains ( [ '--no-prompt' ] ) ,
174+ ) ;
131175 spawnProcessSpy . resetHistory ( ) ;
132- cmd = new SlackCLIProcess ( 'help' , { } , { '--no-prompt' : undefined } ) ;
176+ cmd = new SlackCLIProcess ( [ 'help' ] , { } , { '--no-prompt' : undefined } ) ;
133177 await cmd . execAsync ( ) ;
134- sandbox . assert . neverCalledWithMatch ( spawnProcessSpy , '--no-prompt' ) ;
178+ sandbox . assert . neverCalledWith (
179+ spawnProcessSpy ,
180+ sinon . match . string ,
181+ sinon . match . array . contains ( [ '--no-prompt' ] ) ,
182+ ) ;
135183 } ) ;
136184 } ) ;
137185 } ) ;
0 commit comments