@@ -8,10 +8,11 @@ describe('FormatStream', function() {
88
99 it ( 'should format strings' , function ( done ) {
1010 var stream = new FormatStream ( ) ;
11+ stream . setEncoding ( 'utf8' ) ;
1112 var source = 'foo bar ' ;
1213 var expected = 'Foo bar. ' ;
1314 stream . on ( 'data' , function ( actual ) {
14- assert ( actual , expected ) ;
15+ assert . equal ( actual , expected ) ;
1516 done ( ) ;
1617 } ) ;
1718 stream . on ( 'error' , done ) ;
@@ -20,6 +21,7 @@ describe('FormatStream', function() {
2021
2122 it ( 'should format objects' , function ( done ) {
2223 var stream = new FormatStream ( { objectMode : true } ) ;
24+ stream . setEncoding ( 'utf8' ) ;
2325 var source = { alternatives :
2426 [ {
2527 confidence : 0.881 ,
@@ -33,13 +35,51 @@ describe('FormatStream', function() {
3335 final : true } ] ,
3436 result_index : 0 } ;
3537 stream . on ( 'data' , function ( actual ) {
36- assert ( actual , expected ) ;
38+ assert . equal ( actual , expected ) ;
3739 done ( ) ;
3840 } ) ;
3941 stream . on ( 'error' , done ) ;
4042 stream . write ( source ) ;
4143 } ) ;
4244
45+ it ( 'should drop repeated characters' , function ( done ) {
46+ var stream = new FormatStream ( ) ;
47+ stream . setEncoding ( 'utf8' ) ;
48+ var source = 'I, uh mmmmmmmmm ' ;
49+ var expected = 'I, uh. ' ;
50+ stream . on ( 'data' , function ( actual ) {
51+ assert . equal ( actual , expected ) ;
52+ done ( ) ;
53+ } ) ;
54+ stream . on ( 'error' , done ) ;
55+ stream . write ( source ) ;
56+ } ) ;
57+
58+ it ( 'should not add a period to empty text' , function ( done ) {
59+ var stream = new FormatStream ( ) ;
60+ stream . setEncoding ( 'utf8' ) ;
61+ var source = 'mmmmmmmmm ' ; // this will be stripped by the repeated character check
62+ var expected = ' ' ;
63+ stream . on ( 'data' , function ( actual ) {
64+ assert . equal ( actual , expected ) ;
65+ done ( ) ;
66+ } ) ;
67+ stream . on ( 'error' , done ) ;
68+ stream . write ( source ) ;
69+ } ) ;
70+
71+ it ( 'should not drop portions of numbers when smart formatting is enabled' , function ( done ) {
72+ var stream = new FormatStream ( ) ;
73+ stream . setEncoding ( 'utf8' ) ;
74+ var source = '1000101 ' ;
75+ var expected = '1000101. ' ;
76+ stream . on ( 'data' , function ( actual ) {
77+ assert . equal ( actual , expected ) ;
78+ done ( ) ;
79+ } ) ;
80+ stream . on ( 'error' , done ) ;
81+ stream . write ( source ) ;
82+ } ) ;
4383
4484 /*
4585 { results:
0 commit comments