File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -235,4 +235,42 @@ describe('TimingStream', function() {
235
235
} ) ;
236
236
} ) ;
237
237
238
+ it ( 'should not emit the same transcript twice' , function ( done ) {
239
+ var stream = new TimingStream ( { objectMode : true } ) ;
240
+ var actual = [ ] ;
241
+ stream . on ( 'data' , function ( timedResult ) {
242
+ actual . push ( timedResult ) ;
243
+ } ) ;
244
+ stream . on ( 'error' , done ) ;
245
+
246
+ messageStream . forEach ( function ( msg ) {
247
+ if ( msg . results ) {
248
+ stream . write ( msg ) ;
249
+ }
250
+ } ) ;
251
+
252
+ var numTicks = 37.26 * 1000 ;
253
+
254
+ for ( var i = 0 ; i < numTicks ; i ++ ) {
255
+ clock . tick ( 1 ) ;
256
+ }
257
+
258
+ nextTick ( function ( ) { // write is always async (?)
259
+
260
+ var lastTranscript = '' ;
261
+ actual . forEach ( function ( msg ) {
262
+ var transcript = msg . results [ 0 ] . alternatives [ 0 ] . transcript ;
263
+ var final = msg . results [ 0 ] . final ;
264
+ // a final result may have the same text as the previous result (regardless of weather the previous was interim or final)
265
+ if ( ! final ) {
266
+ assert . notEqual ( transcript , lastTranscript ) ;
267
+ assert . notEqual ( transcript . trim ( ) , lastTranscript . trim ( ) ) ;
268
+ }
269
+ lastTranscript = transcript ;
270
+ } ) ;
271
+
272
+ done ( ) ;
273
+ } ) ;
274
+ } ) ;
275
+
238
276
} ) ;
You can’t perform that action at this time.
0 commit comments