@@ -95,56 +95,6 @@ describe('speech_to_text', function() {
9595 } ) ;
9696 } ) ;
9797
98- describe ( 'observeResult()' , function ( ) {
99- it ( 'should check no parameters provided' , function ( ) {
100- speech_to_text . observeResult ( { } , missingParameter ) ;
101- speech_to_text . observeResult ( null , missingParameter ) ;
102- } ) ;
103-
104- it ( 'should generate a valid payload' , function ( done ) {
105- const expectation = nock ( 'http://ibm.com:80' , {
106- encodedQueryParams : true ,
107- } )
108- . matchHeader ( 'Cookie' , / S E S S I O N I D = b a r / )
109- . get ( '/v1/sessions/foo/observe_result' )
110- . reply ( 200 , { } ) ;
111-
112- speech_to_text . observeResult (
113- {
114- session_id : 'foo' ,
115- cookie_session : 'bar' ,
116- } ,
117- err => {
118- assert . ifError ( err ) ;
119- assert ( expectation . isDone ( ) ) ;
120- done ( ) ;
121- }
122- ) ;
123- } ) ;
124-
125- it ( 'should generate a valid payload with interim_results enabled' , function ( done ) {
126- const expectation = nock ( 'http://ibm.com:80' , {
127- encodedQueryParams : true ,
128- } )
129- . matchHeader ( 'Cookie' , / S E S S I O N I D = b a r / )
130- . get ( '/v1/sessions/foo/observe_result?interim_results=true' )
131- . reply ( 200 , { } ) ;
132-
133- speech_to_text . observeResult (
134- {
135- session_id : 'foo' ,
136- cookie_session : 'bar' ,
137- interim_results : true ,
138- } ,
139- err => {
140- assert . ifError ( err ) ;
141- assert ( expectation . isDone ( ) ) ;
142- done ( ) ;
143- }
144- ) ;
145- } ) ;
146- } ) ;
147-
14898 describe ( 'recognize()' , function ( ) {
14999 it ( 'should check no parameters provided' , function ( ) {
150100 speech_to_text . recognize ( { } , missingParameter ) ;
@@ -180,71 +130,6 @@ describe('speech_to_text', function() {
180130 } ) ;
181131 } ) ;
182132
183- describe ( 'recognizeLive()' , function ( ) {
184- const path = '/v1/sessions/foo/recognize' ;
185- const payload = {
186- session_id : 'foo' ,
187- cookie_session : 'foobar' ,
188- content_type : 'audio/l16; rate=41100' ,
189- } ;
190- const service_response = {
191- result : [
192- {
193- alternative : [
194- {
195- transcript : 'one two three' ,
196- } ,
197- ] ,
198- final : true ,
199- } ,
200- ] ,
201- result_index : 0 ,
202- } ;
203-
204- it ( 'should check no parameters provided' , function ( ) {
205- speech_to_text . recognizeLive ( { } , missingParameter ) ;
206- speech_to_text . recognizeLive ( null , missingParameter ) ;
207- speech_to_text . recognizeLive ( { cookie_session : 'foo' } , missingParameter ) ;
208- speech_to_text . recognizeLive ( { content_type : 'bar' } , missingParameter ) ;
209- speech_to_text . recognizeLive ( { continuous : 'false' } , missingParameter ) ;
210- } ) ;
211-
212- it ( 'should generate a valid payload' , function ( done ) {
213- nock ( service . url )
214- . post ( path )
215- . delay ( 300 )
216- . reply ( 200 , service_response ) ;
217-
218- const req = speech_to_text . recognizeLive ( payload , function ( err , res ) {
219- assert . equal ( JSON . stringify ( service_response ) , JSON . stringify ( res ) ) ;
220- done ( ) ;
221- } ) ;
222- assert . equal ( req . path , path ) ;
223- assert . equal ( req . _headers [ 'content-type' ] , payload . content_type ) ;
224- assert . equal ( req . _headers [ 'transfer-encoding' ] , 'chunked' ) ;
225- assert . ok ( req . _headers [ 'cookie' ] . indexOf ( 'SESSIONID=' + payload . cookie_session ) !== - 1 ) ;
226-
227- req . end ( ) ;
228- } ) ;
229-
230- it ( 'should generate a valid response' , function ( done ) {
231- nock ( service . url )
232- . post ( path )
233- . delay ( 300 )
234- . reply ( 200 , service_response ) ;
235-
236- const req = speech_to_text . recognizeLive ( payload , function ( err , res ) {
237- assert . equal ( JSON . stringify ( service_response ) , JSON . stringify ( res ) ) ;
238- done ( ) ;
239- } ) ;
240- req . write ( Buffer . from ( 'one' , 'utf-8' ) ) ;
241- req . write ( Buffer . from ( 'two' , 'utf-8' ) ) ;
242- req . write ( Buffer . from ( 'three' , 'utf-8' ) ) ;
243- assert . equal ( req . path , path ) ;
244- req . end ( ) ;
245- } ) ;
246- } ) ;
247-
248133 describe ( 'recognizeUsingWebSocket()' , function ( ) {
249134 it ( 'should return a stream' , function ( ) {
250135 assert ( isStream ( speech_to_text . recognizeUsingWebSocket ( ) ) ) ;
0 commit comments