File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
packages/google-cloud-speech Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -483,6 +483,10 @@ Speech.formatResults_ = function(resultSets, verboseMode) {
483
483
Speech . prototype . createRecognizeStream = function ( config ) {
484
484
var self = this ;
485
485
486
+ if ( ! config ) {
487
+ throw new Error ( 'A recognize request requires a configuration object.' ) ;
488
+ }
489
+
486
490
var verboseMode = config . verbose === true ;
487
491
delete config . verbose ;
488
492
@@ -657,6 +661,10 @@ Speech.prototype.operation = function(name) {
657
661
Speech . prototype . recognize = function ( file , config , callback ) {
658
662
var self = this ;
659
663
664
+ if ( ! is . object ( config ) ) {
665
+ throw new Error ( 'A recognize request requires a configuration object.' ) ;
666
+ }
667
+
660
668
config = extend ( { } , config ) ;
661
669
662
670
if ( ! config . encoding ) {
Original file line number Diff line number Diff line change @@ -472,6 +472,12 @@ describe('Speech', function() {
472
472
} ;
473
473
} ) ;
474
474
475
+ it ( 'should throw if an object is not provided' , function ( ) {
476
+ assert . throws ( function ( ) {
477
+ speech . createRecognizeStream ( ) ;
478
+ } , / A r e c o g n i z e r e q u e s t r e q u i r e s a c o n f i g u r a t i o n o b j e c t \. / ) ;
479
+ } ) ;
480
+
475
481
it ( 'should make the correct request once writing started' , function ( done ) {
476
482
speech . api . Speech = {
477
483
streamingRecognize : function ( ) {
@@ -698,6 +704,12 @@ describe('Speech', function() {
698
704
} ;
699
705
} ) ;
700
706
707
+ it ( 'should throw if an object is not provided' , function ( ) {
708
+ assert . throws ( function ( ) {
709
+ speech . recognize ( FILE , assert . ifError ) ;
710
+ } , / A r e c o g n i z e r e q u e s t r e q u i r e s a c o n f i g u r a t i o n o b j e c t \. / ) ;
711
+ } ) ;
712
+
701
713
it ( 'should find the files' , function ( done ) {
702
714
Speech . findFile_ = function ( file ) {
703
715
assert . strictEqual ( file , FILE ) ;
You can’t perform that action at this time.
0 commit comments