@@ -42,29 +42,38 @@ describe('Utility Functions', () => {
4242 } ) ;
4343
4444 describe ( 'numberFormat' , ( ) => {
45- it ( 'should return false for invalid currency code' , ( ) => {
45+ it ( 'returns the plain number as string for an invalid currency code' , ( ) => {
4646 const result = numberFormat ( 'INVALID' , 100 ) ;
47- expect ( result ) . to . equal ( false ) ;
47+ expect ( result ) . to . equal ( '100' ) ;
4848 } ) ;
4949
50- it ( 'should return original number if no locale found ' , ( ) => {
50+ it ( 'formats the number using the currency locale ' , ( ) => {
5151 const result = numberFormat ( 'USD' , 1234.56 ) ;
52- expect ( result ) . to . not . be . false ;
52+ expect ( result ) . to . equal ( '1,234.56' ) ;
5353 } ) ;
5454
55- it ( 'should return original number for NaN input' , ( ) => {
55+ it ( 'returns a string for NaN input' , ( ) => {
5656 const result = numberFormat ( 'USD' , NaN ) ;
57- expect ( result ) . to . be . NaN ;
57+ expect ( result ) . to . equal ( ' NaN' ) ;
5858 } ) ;
5959
60- it ( 'should handle zero correctly' , ( ) => {
60+ it ( 'handles zero correctly' , ( ) => {
6161 const result = numberFormat ( 'USD' , 0 ) ;
62- expect ( result ) . to . not . be . false ;
62+ expect ( result ) . to . equal ( '0' ) ;
6363 } ) ;
6464
65- it ( 'should handle negative numbers' , ( ) => {
65+ it ( 'handles negative numbers' , ( ) => {
6666 const result = numberFormat ( 'USD' , - 100 ) ;
67- expect ( result ) . to . not . be . false ;
67+ expect ( result ) . to . equal ( '-100' ) ;
68+ } ) ;
69+
70+ it ( 'always returns a string' , ( ) => {
71+ const results = [
72+ numberFormat ( 'INVALID' , 100 ) ,
73+ numberFormat ( 'USD' , 1000 ) ,
74+ numberFormat ( 'USD' , NaN ) ,
75+ ] ;
76+ results . forEach ( result => expect ( result ) . to . be . a ( 'string' ) ) ;
6877 } ) ;
6978 } ) ;
7079
0 commit comments