anuragshas's picture
chore: basic linting
38c96d1
raw
history blame
1.22 kB
const assert = require('assert');
const { numberToWords } = require('../script.js');
// Test cases for Indian number-to-words conversion (Crore/Lakh system)
const cases = [
{ num: 0, expected: 'Zero' },
{ num: 5, expected: 'Five' },
{ num: 15, expected: 'Fifteen' },
{ num: 75, expected: 'Seventy Five' },
{ num: 100, expected: 'One Hundred' },
{ num: 569, expected: 'Five Hundred and Sixty Nine' },
{ num: 1000, expected: 'One Thousand' },
{ num: 1100, expected: 'One Thousand One Hundred' },
{ num: 1234, expected: 'One Thousand Two Hundred and Thirty Four' },
{ num: 10000, expected: 'Ten Thousand' },
{ num: 54000, expected: 'Fifty Four Thousand' },
{ num: 100000, expected: 'One Lakh' },
{ num: 510000, expected: 'Five Lakh Ten Thousand' },
{ num: 9999999, expected: 'Ninety Nine Lakh Ninety Nine Thousand Nine Hundred and Ninety Nine' },
{ num: 10000000, expected: 'One Crore' },
{ num: 12500000, expected: 'One Crore Twenty Five Lakh' },
];
cases.forEach(({ num, expected }) => {
const actual = numberToWords(num);
assert.strictEqual(
actual,
expected,
`${num} => "${actual}" (expected "${expected}")`
);
});
console.log('✅ All numberToWords tests passed');