@@ -18,14 +18,20 @@ describe("Should convert all the valid numeric strings to number", () => {
18
18
expect ( toNumber ( "12+12" ) ) . toEqual ( "12+12" ) ;
19
19
expect ( toNumber ( "1212+" ) ) . toEqual ( "1212+" ) ;
20
20
} )
21
- it ( "should parse hexaDecimal values" , ( ) => {
21
+ it ( "should parse hexadecimal values" , ( ) => {
22
22
expect ( toNumber ( "0x2f" ) ) . toEqual ( 47 ) ;
23
23
expect ( toNumber ( "-0x2f" ) ) . toEqual ( - 47 ) ;
24
24
expect ( toNumber ( "0x2f" , { hex : true } ) ) . toEqual ( 47 ) ;
25
25
expect ( toNumber ( "-0x2f" , { hex : true } ) ) . toEqual ( - 47 ) ;
26
26
expect ( toNumber ( "0x2f" , { hex : false } ) ) . toEqual ( "0x2f" ) ;
27
27
expect ( toNumber ( "-0x2f" , { hex : false } ) ) . toEqual ( "-0x2f" ) ;
28
28
} )
29
+ it ( "should not parse strings with 0x embedded" , ( ) => {
30
+ expect ( toNumber ( "0xzz" ) ) . toEqual ( "0xzz" ) ;
31
+ expect ( toNumber ( "iweraf0x123qwerqwer" ) ) . toEqual ( "iweraf0x123qwerqwer" ) ;
32
+ expect ( toNumber ( "1230x55" ) ) . toEqual ( "1230x55" ) ;
33
+ expect ( toNumber ( "JVBERi0xLjMNCiXi48" ) ) . toEqual ( "JVBERi0xLjMNCiXi48" ) ;
34
+ } )
29
35
it ( "leading zeros" , ( ) => {
30
36
expect ( toNumber ( "06" ) ) . toEqual ( 6 ) ;
31
37
expect ( toNumber ( "06" , { leadingZeros : true } ) ) . toEqual ( 6 ) ;
@@ -103,5 +109,4 @@ describe("Should convert all the valid numeric strings to number", () => {
103
109
it ( "should ignore sorrounded spaces " , ( ) => {
104
110
expect ( toNumber ( " +1212 " ) ) . toEqual ( 1212 ) ;
105
111
} )
106
-
107
- } ) ;
112
+ } ) ;
0 commit comments