@@ -63,17 +63,32 @@ describe("Stats", function() {
6363 var toStringOptions = {
6464 colors : false
6565 } ;
66+ var hasColorSetting = false ;
67+
6668 if ( typeof options . stats !== "undefined" ) {
6769 toStringOptions = options . stats ;
70+
71+ hasColorSetting = typeof options . stats . colors !== "undefined" ;
6872 }
6973
7074 var actual = stats . toString ( toStringOptions ) ;
7175 ( typeof actual ) . should . be . eql ( "string" ) ;
72- actual =
73- actual . replace ( / \u001b \[ [ 0 - 9 ; ] * m / g, "" )
76+ if ( ! hasColorSetting ) {
77+ actual = actual
78+ . replace ( / \u001b \[ [ 0 - 9 ; ] * m / g, "" )
79+ . replace ( / [ 0 - 9 ] + ( \s ? m s ) / g, "X$1" ) ;
80+ } else {
81+ actual = actual
82+ . replace ( / \u001b \[ 1 m \u001b \[ ( [ 0 - 9 ; ] * ) m / g, "<CLR=$1,BOLD>" )
83+ . replace ( / \u001b \[ 1 m / g, "<CLR=BOLD>" )
84+ . replace ( / \u001b \[ 3 9 m \u001b \[ 2 2 m / g, "</CLR>" )
85+ . replace ( / \u001b \[ ( [ 0 - 9 ; ] * ) m / g, "<CLR=$1>" )
86+ . replace ( / [ 0 - 9 ] + ( < \/ C L R > ) ? ( \s ? m s ) / g, "X$1$2" ) ;
87+ }
88+
89+ actual = actual
7490 . replace ( / \r \n ? / g, "\n" )
7591 . replace ( / [ \t ] * V e r s i o n : .+ \n / g, "" )
76- . replace ( / [ 0 - 9 ] + ( \s ? m s ) / g, "X$1" )
7792 . replace ( path . join ( base , testName ) , "Xdir/" + testName ) ;
7893 var expected = fs . readFileSync ( path . join ( base , testName , "expected.txt" ) , "utf-8" ) . replace ( / \r / g, "" ) ;
7994 if ( actual !== expected ) {
0 commit comments