|
| 1 | +import { isNumeric } from '../IsNumeric.js' |
| 2 | + |
| 3 | +describe('isNumeric', () => { |
| 4 | + test("isNumeric('123') returns true", () => { |
| 5 | + expect(isNumeric('123')).toBe(true) |
| 6 | + }) |
| 7 | + |
| 8 | + test("isNumeric('-45.6') returns true", () => { |
| 9 | + expect(isNumeric('-45.6')).toBe(true) |
| 10 | + }) |
| 11 | + |
| 12 | + test("isNumeric('0') returns true", () => { |
| 13 | + expect(isNumeric('0')).toBe(true) |
| 14 | + }) |
| 15 | + |
| 16 | + test("isNumeric('3.14') returns true", () => { |
| 17 | + expect(isNumeric('3.14')).toBe(true) |
| 18 | + }) |
| 19 | + |
| 20 | + test("isNumeric('abc') returns false", () => { |
| 21 | + expect(isNumeric('abc')).toBe(false) |
| 22 | + }) |
| 23 | + |
| 24 | + test("isNumeric('12.3.4') returns false", () => { |
| 25 | + expect(isNumeric('12.3.4')).toBe(false) |
| 26 | + }) |
| 27 | + |
| 28 | + test("isNumeric('') returns false", () => { |
| 29 | + expect(isNumeric('')).toBe(false) |
| 30 | + }) |
| 31 | + |
| 32 | + test("isNumeric(' ') returns false", () => { |
| 33 | + expect(isNumeric(' ')).toBe(false) |
| 34 | + }) |
| 35 | + |
| 36 | + test("isNumeric('123abc') returns false", () => { |
| 37 | + expect(isNumeric('123abc')).toBe(false) |
| 38 | + }) |
| 39 | + |
| 40 | + test("isNumeric('-0') returns true", () => { |
| 41 | + expect(isNumeric('-0')).toBe(true) |
| 42 | + }) |
| 43 | + |
| 44 | + test('throws TypeError for non-string input', () => { |
| 45 | + expect(() => isNumeric(123)).toThrow(TypeError) |
| 46 | + }) |
| 47 | + |
| 48 | + test('throws TypeError for null input', () => { |
| 49 | + expect(() => isNumeric(null)).toThrow(TypeError) |
| 50 | + }) |
| 51 | +}) |
0 commit comments