@@ -38,17 +38,17 @@ describe('ML - string utils', () => {
3838 initial_record_score : 0 ,
3939 } ;
4040
41- test ( 'returns correct values without URI encoding' , ( ) => {
41+ test ( 'should return correct values without URI encoding' , ( ) => {
4242 const result = replaceStringTokens ( 'user=$user$,time=$timestamp$' , testRecord , false ) ;
4343 expect ( result ) . toBe ( "user=Des O'Connor,time=1454890500000" ) ;
4444 } ) ;
4545
46- test ( 'returns correct values for missing token without URI encoding' , ( ) => {
46+ test ( 'should return correct values for missing token without URI encoding' , ( ) => {
4747 const result = replaceStringTokens ( 'user=$username$,time=$timestamp$' , testRecord , false ) ;
4848 expect ( result ) . toBe ( 'user=$username$,time=1454890500000' ) ;
4949 } ) ;
5050
51- test ( 'returns correct values with URI encoding' , ( ) => {
51+ test ( 'should return correct values with URI encoding' , ( ) => {
5252 const testString1 = 'https://www.google.co.uk/webhp#q=$testfield1$' ;
5353 const testString2 = 'https://www.google.co.uk/webhp#q=$testfield2$' ;
5454 const testString3 = 'https://www.google.co.uk/webhp#q=$testfield3$' ;
@@ -65,15 +65,15 @@ describe('ML - string utils', () => {
6565 expect ( result4 ) . toBe ( "https://www.google.co.uk/webhp#q=Des%20O'Connor" ) ;
6666 } ) ;
6767
68- test ( 'returns correct values for missing token with URI encoding' , ( ) => {
68+ test ( 'should return correct values for missing token with URI encoding' , ( ) => {
6969 const testString = 'https://www.google.co.uk/webhp#q=$username$&time=$timestamp$' ;
7070 const result = replaceStringTokens ( testString , testRecord , true ) ;
7171 expect ( result ) . toBe ( 'https://www.google.co.uk/webhp#q=$username$&time=1454890500000' ) ;
7272 } ) ;
7373 } ) ;
7474
7575 describe ( 'detectorToString' , ( ) => {
76- test ( 'returns the correct descriptions for detectors' , ( ) => {
76+ test ( 'should return the correct descriptions for detectors' , ( ) => {
7777 const detector1 : Detector = {
7878 function : 'count' ,
7979 } ;
@@ -102,7 +102,7 @@ describe('ML - string utils', () => {
102102 } ) ;
103103
104104 describe ( 'toLocaleString' , ( ) => {
105- test ( 'returns correct comma placement for large numbers' , ( ) => {
105+ test ( 'should return correct comma placement for large numbers' , ( ) => {
106106 expect ( toLocaleString ( 1 ) ) . toBe ( '1' ) ;
107107 expect ( toLocaleString ( 10 ) ) . toBe ( '10' ) ;
108108 expect ( toLocaleString ( 100 ) ) . toBe ( '100' ) ;
@@ -114,10 +114,14 @@ describe('ML - string utils', () => {
114114 expect ( toLocaleString ( 100000000 ) ) . toBe ( '100,000,000' ) ;
115115 expect ( toLocaleString ( 1000000000 ) ) . toBe ( '1,000,000,000' ) ;
116116 } ) ;
117+ test ( 'should return empty string for undefined or null' , ( ) => {
118+ expect ( toLocaleString ( undefined ) ) . toBe ( '' ) ;
119+ expect ( toLocaleString ( null ) ) . toBe ( '' ) ;
120+ } ) ;
117121 } ) ;
118122
119123 describe ( 'mlEscape' , ( ) => {
120- test ( 'returns correct escaping of characters' , ( ) => {
124+ test ( 'should return correct escaping of characters' , ( ) => {
121125 expect ( mlEscape ( 'foo&bar' ) ) . toBe ( 'foo&bar' ) ;
122126 expect ( mlEscape ( 'foo<bar' ) ) . toBe ( 'foo<bar' ) ;
123127 expect ( mlEscape ( 'foo>bar' ) ) . toBe ( 'foo>bar' ) ;
@@ -128,7 +132,7 @@ describe('ML - string utils', () => {
128132 } ) ;
129133
130134 describe ( 'escapeForElasticsearchQuery' , ( ) => {
131- test ( 'returns correct escaping of reserved elasticsearch characters' , ( ) => {
135+ test ( 'should return correct escaping of reserved elasticsearch characters' , ( ) => {
132136 expect ( escapeForElasticsearchQuery ( 'foo+bar' ) ) . toBe ( 'foo\\+bar' ) ;
133137 expect ( escapeForElasticsearchQuery ( 'foo-bar' ) ) . toBe ( 'foo\\-bar' ) ;
134138 expect ( escapeForElasticsearchQuery ( 'foo=bar' ) ) . toBe ( 'foo\\=bar' ) ;
0 commit comments