|
| 1 | +import { isBounceNumber } from '../BounceNumber.js' |
| 2 | + |
| 3 | +describe('isBounceNumber', () => { |
| 4 | + test('155349 is a bounce number', () => { |
| 5 | + expect(isBounceNumber(155349)).toBe(true) |
| 6 | + }) |
| 7 | + |
| 8 | + test('121 is a bounce number', () => { |
| 9 | + expect(isBounceNumber(121)).toBe(true) |
| 10 | + }) |
| 11 | + |
| 12 | + test('1234 is NOT a bounce number (increasing)', () => { |
| 13 | + expect(isBounceNumber(1234)).toBe(false) |
| 14 | + }) |
| 15 | + |
| 16 | + test('9876 is NOT a bounce number (decreasing)', () => { |
| 17 | + expect(isBounceNumber(9876)).toBe(false) |
| 18 | + }) |
| 19 | + |
| 20 | + test('1111 is NOT a bounce number (all same)', () => { |
| 21 | + expect(isBounceNumber(1111)).toBe(false) |
| 22 | + }) |
| 23 | + |
| 24 | + test('single digit is NOT a bounce number', () => { |
| 25 | + expect(isBounceNumber(5)).toBe(false) |
| 26 | + }) |
| 27 | + |
| 28 | + test('132 is a bounce number', () => { |
| 29 | + expect(isBounceNumber(132)).toBe(true) |
| 30 | + }) |
| 31 | + |
| 32 | + test('321 is NOT a bounce number (decreasing)', () => { |
| 33 | + expect(isBounceNumber(321)).toBe(false) |
| 34 | + }) |
| 35 | + |
| 36 | + test('123454321 is a bounce number', () => { |
| 37 | + expect(isBounceNumber(123454321)).toBe(true) |
| 38 | + }) |
| 39 | + |
| 40 | + test('throws TypeError for zero', () => { |
| 41 | + expect(() => isBounceNumber(0)).toThrow(TypeError) |
| 42 | + }) |
| 43 | + |
| 44 | + test('throws TypeError for negative input', () => { |
| 45 | + expect(() => isBounceNumber(-121)).toThrow(TypeError) |
| 46 | + }) |
| 47 | + |
| 48 | + test('throws TypeError for float input', () => { |
| 49 | + expect(() => isBounceNumber(1.5)).toThrow(TypeError) |
| 50 | + }) |
| 51 | +}) |
0 commit comments