@@ -8,10 +8,11 @@ describe('FormatStream', function() {
8
8
9
9
it ( 'should format strings' , function ( done ) {
10
10
var stream = new FormatStream ( ) ;
11
+ stream . setEncoding ( 'utf8' ) ;
11
12
var source = 'foo bar ' ;
12
13
var expected = 'Foo bar. ' ;
13
14
stream . on ( 'data' , function ( actual ) {
14
- assert ( actual , expected ) ;
15
+ assert . equal ( actual , expected ) ;
15
16
done ( ) ;
16
17
} ) ;
17
18
stream . on ( 'error' , done ) ;
@@ -20,6 +21,7 @@ describe('FormatStream', function() {
20
21
21
22
it ( 'should format objects' , function ( done ) {
22
23
var stream = new FormatStream ( { objectMode : true } ) ;
24
+ stream . setEncoding ( 'utf8' ) ;
23
25
var source = { alternatives :
24
26
[ {
25
27
confidence : 0.881 ,
@@ -33,13 +35,51 @@ describe('FormatStream', function() {
33
35
final : true } ] ,
34
36
result_index : 0 } ;
35
37
stream . on ( 'data' , function ( actual ) {
36
- assert ( actual , expected ) ;
38
+ assert . equal ( actual , expected ) ;
37
39
done ( ) ;
38
40
} ) ;
39
41
stream . on ( 'error' , done ) ;
40
42
stream . write ( source ) ;
41
43
} ) ;
42
44
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
+ } ) ;
43
83
44
84
/*
45
85
{ results:
0 commit comments