@@ -65,7 +65,7 @@ describe('translate:translate', function () {
65
65
assert . equal ( callback . firstCall . args . length , 2 , 'callback received 2 arguments' ) ;
66
66
assert . ifError ( callback . firstCall . args [ 0 ] , 'callback did not receive error' ) ;
67
67
assert . strictEqual ( callback . firstCall . args [ 1 ] , sample . mocks . result , 'callback received result' ) ;
68
- assert ( console . log . calledWith ( 'Detected %s with confidence %d' , 'English' , sample . mocks . result . confidence ) ) ;
68
+ assert ( console . log . calledWith ( 'Detected %s (%s) with confidence %d' , 'English' , 'en ', sample . mocks . result . confidence ) ) ;
69
69
} ) ;
70
70
71
71
it ( 'should handle error' , function ( ) {
@@ -137,7 +137,7 @@ describe('translate:translate', function () {
137
137
assert . equal ( callback . firstCall . args . length , 2 , 'callback received 2 arguments' ) ;
138
138
assert . ifError ( callback . firstCall . args [ 0 ] , 'callback did not receive error' ) ;
139
139
assert . strictEqual ( callback . firstCall . args [ 1 ] , sample . mocks . translation , 'callback received result' ) ;
140
- assert ( console . log . calledWith ( 'Translated text to %s' , 'Russian' ) ) ;
140
+ assert ( console . log . calledWith ( 'Translated text to %s: ' , 'Russian' ) ) ;
141
141
} ) ;
142
142
143
143
it ( 'should handle error' , function ( ) {
@@ -166,23 +166,31 @@ describe('translate:translate', function () {
166
166
167
167
sinon . stub ( program , 'detectLanguage' ) ;
168
168
program . main ( [ 'detect' , text , '-k' , apiKey ] ) ;
169
- assert ( program . detectLanguage . calledOnce ) ;
169
+ assert . equal ( program . detectLanguage . calledOnce , true ) ;
170
+ assert . deepEqual ( program . detectLanguage . firstCall . args . slice ( 0 , - 1 ) , [ text , apiKey ] ) ;
170
171
} ) ;
171
172
172
173
it ( 'should call listLanguages' , function ( ) {
173
174
var program = getSample ( ) . program ;
174
175
175
176
sinon . stub ( program , 'listLanguages' ) ;
176
177
program . main ( [ 'list' , '-k' , apiKey ] ) ;
177
- assert ( program . listLanguages . calledOnce ) ;
178
+ assert . equal ( program . listLanguages . calledOnce , true ) ;
179
+ assert . deepEqual ( program . listLanguages . firstCall . args . slice ( 0 , - 1 ) , [ apiKey ] ) ;
178
180
} ) ;
179
181
180
182
it ( 'should call translateText' , function ( ) {
181
183
var program = getSample ( ) . program ;
182
184
183
185
sinon . stub ( program , 'translateText' ) ;
184
186
program . main ( [ 'translate' , text , '-k' , apiKey , '-t' , 'ru' ] ) ;
185
- assert ( program . translateText . calledOnce ) ;
187
+ assert . equal ( program . translateText . calledOnce , true ) ;
188
+ assert . deepEqual ( program . translateText . firstCall . args . slice ( 0 , - 1 ) , [ {
189
+ text : text ,
190
+ to : 'ru' ,
191
+ from : undefined ,
192
+ apiKey : apiKey
193
+ } ] ) ;
186
194
} ) ;
187
195
} ) ;
188
196
} ) ;
0 commit comments