@@ -321,4 +321,82 @@ describe('written-number', function() {
321321 ) ;
322322 } ) ;
323323 } ) ;
324+
325+ describe ( 'writtenNumber(n, { lang: \'enIndian\', ... })' , function ( ) {
326+ before ( function ( ) {
327+ writtenNumber . defaults . lang = 'enIndian' ;
328+ } ) ;
329+
330+ it ( 'gets exposed' , function ( ) {
331+ should . exist ( writtenNumber ) ;
332+ writtenNumber . should . be . instanceof ( Function ) ;
333+ } ) ;
334+
335+ it ( 'doesn\'t blow up weirdly with invalid input' , function ( ) {
336+ writtenNumber ( 'asdfasdfasdf' ) . should . equal ( '' ) ;
337+ writtenNumber ( '0.as' ) . should . equal ( '' ) ;
338+ writtenNumber ( '0.123' ) . should . equal ( 'zero' ) ;
339+ writtenNumber ( '0.8' ) . should . equal ( 'one' ) ;
340+ writtenNumber ( '2.8' ) . should . equal ( 'three' ) ;
341+ writtenNumber ( 'asdf.8' ) . should . equal ( '' ) ;
342+ writtenNumber ( '120391938123..' ) . should . equal ( '' ) ;
343+ writtenNumber ( 1000000000 ) . should . equal ( 'one hundred crore' ) ;
344+ writtenNumber ( '1/3' ) . should . equal ( '' ) ;
345+ writtenNumber ( 1 / 3 ) . should . equal ( 'zero' ) ;
346+ writtenNumber ( '1/2' ) . should . equal ( '' ) ;
347+ writtenNumber ( '1.123/2' ) . should . equal ( '' ) ;
348+ } ) ;
349+
350+ it ( 'correctly converts numbers < 10' , function ( ) {
351+ writtenNumber ( 1000000000 ) . should . equal ( 'one hundred crore' ) ;
352+ writtenNumber ( 3 ) . should . equal ( 'three' ) ;
353+ writtenNumber ( 8 ) . should . equal ( 'eight' ) ;
354+ } ) ;
355+
356+ it ( 'correctly converts numbers < 20' , function ( ) {
357+ writtenNumber ( 13 ) . should . equal ( 'thirteen' ) ;
358+ writtenNumber ( 19 ) . should . equal ( 'nineteen' ) ;
359+ } ) ;
360+
361+ it ( 'correctly converts numbers < 100' , function ( ) {
362+ writtenNumber ( 20 ) . should . equal ( 'twenty' ) ;
363+ writtenNumber ( 25 ) . should . equal ( 'twenty-five' ) ;
364+ writtenNumber ( 88 ) . should . equal ( 'eighty-eight' ) ;
365+ writtenNumber ( 73 ) . should . equal ( 'seventy-three' ) ;
366+ } ) ;
367+
368+ it ( 'correctly converts numbers < 1000' , function ( ) {
369+ writtenNumber ( 200 ) . should . equal ( 'two hundred' ) ;
370+ writtenNumber ( 242 ) . should . equal ( 'two hundred and forty-two' ) ;
371+ writtenNumber ( 1234 ) . should . equal (
372+ 'one thousand two hundred and thirty-four'
373+ ) ;
374+ writtenNumber ( 4323 ) . should . equal (
375+ 'four thousand three hundred and twenty-three'
376+ ) ;
377+ } ) ;
378+
379+ it ( 'correctly converts numbers > 1000' , function ( ) {
380+ writtenNumber ( 4323000 ) . should . equal (
381+ 'forty-three lakh twenty-three thousand'
382+ ) ;
383+ writtenNumber ( 4323055 ) . should . equal (
384+ 'forty-three lakh twenty-three thousand and fifty-five'
385+ ) ;
386+ writtenNumber ( 1570025 ) . should . equal (
387+ 'fifteen lakh seventy thousand and twenty-five'
388+ ) ;
389+ } ) ;
390+
391+ it ( 'correctly converts numbers > 1 000 000 000' , function ( ) {
392+ writtenNumber ( 1000000000 ) . should . equal ( 'one hundred crore' ) ;
393+ writtenNumber ( 2580000000 ) . should . equal (
394+ 'two hundred fifty-eight crore'
395+ ) ;
396+ writtenNumber ( 1000000000000 ) . should . equal ( 'one lakh crore' ) ;
397+ writtenNumber ( 3627000000000 ) . should . equal (
398+ 'three lakh sixty-two thousand seven hundred crore'
399+ ) ;
400+ } ) ;
401+ } ) ;
324402} ) ;
0 commit comments