nepali-number-system
Version:
Convert numbers to Nepali words representation, A TypeScript library to convert numbers into Nepali words, supporting both Nepali and English outputs
51 lines • 2.29 kB
JavaScript
import { renderHook, act } from '@testing-library/react';
import { useNepaliNumberSystem } from '../react-hook';
describe('useNepaliNumberSystem', () => {
it('should convert 123 to Nepali words', () => {
const { result } = renderHook(() => useNepaliNumberSystem());
let output = '';
act(() => {
output = result.current.convert('123', 'np');
});
expect(output).toMatch(/एक सय तेइस|एक सय तेइस/);
expect(result.current.result).toMatch(/एक सय तेइस|एक सय तेइस/);
});
it('should convert 123 to English words', () => {
const { result } = renderHook(() => useNepaliNumberSystem());
let output = '';
act(() => {
output = result.current.convert('123', 'en');
});
expect(output).toMatch(/One Hundred Twenty Three/);
expect(result.current.result).toMatch(/One Hundred Twenty Three/);
});
it('should convert large number with decimals to Nepali words', () => {
const { result } = renderHook(() => useNepaliNumberSystem());
let output = '';
act(() => {
output = result.current.convert('4567896789678.6788', 'np');
});
expect(output).toMatch(/रुपैयाँ/);
expect(output).toMatch(/पैसा/);
expect(output).toMatch(/खर्ब/);
expect(output).toMatch(/अर्ब/);
expect(output).toMatch(/करोड/);
expect(result.current.result).toMatch(/रुपैयाँ/);
expect(result.current.result).toMatch(/पैसा/);
});
it('should convert large number with decimals to English words', () => {
const { result } = renderHook(() => useNepaliNumberSystem());
let output = '';
act(() => {
output = result.current.convert('4567896789678.6788', 'en');
});
expect(output).toMatch(/Rupees/);
expect(output).toMatch(/Paisa/);
expect(output).toMatch(/Kharab/);
expect(output).toMatch(/Arab/);
expect(output).toMatch(/Crore/);
expect(result.current.result).toMatch(/Rupees/);
expect(result.current.result).toMatch(/Paisa/);
});
});
//# sourceMappingURL=react-hook.test.js.map