Skip to content

Commit a52705f

Browse files
committed
test to catch an ordering bug that was fixed in previous release
1 parent a0f0562 commit a52705f

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

test/timing-stream-spec.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,4 +235,42 @@ describe('TimingStream', function() {
235235
});
236236
});
237237

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+
238276
});

0 commit comments

Comments
 (0)