|
1 | | -import { isAutomorphic } from '../AutomorphicNumber' |
| 1 | +import { isAutomorphicNumber } from '../AutomorphicNumber.js' |
2 | 2 |
|
3 | | -describe('AutomorphicNumber', () => { |
4 | | - it('should throw Error when n is String', () => { |
5 | | - expect(() => isAutomorphic('qwerty')).toThrow() |
| 3 | +describe('isAutomorphicNumber', () => { |
| 4 | + test('1 is automorphic (1² = 1)', () => { |
| 5 | + expect(isAutomorphicNumber(1)).toBe(true) |
6 | 6 | }) |
7 | | - it('should throw Error when n is floating point', () => { |
8 | | - expect(() => isAutomorphic(13.6)).toThrow() |
| 7 | + |
| 8 | + test('5 is automorphic (5² = 25)', () => { |
| 9 | + expect(isAutomorphicNumber(5)).toBe(true) |
| 10 | + }) |
| 11 | + |
| 12 | + test('6 is automorphic (6² = 36)', () => { |
| 13 | + expect(isAutomorphicNumber(6)).toBe(true) |
| 14 | + }) |
| 15 | + |
| 16 | + test('25 is automorphic (25² = 625)', () => { |
| 17 | + expect(isAutomorphicNumber(25)).toBe(true) |
| 18 | + }) |
| 19 | + |
| 20 | + test('76 is automorphic (76² = 5776)', () => { |
| 21 | + expect(isAutomorphicNumber(76)).toBe(true) |
| 22 | + }) |
| 23 | + |
| 24 | + test('376 is automorphic (376² = 141376)', () => { |
| 25 | + expect(isAutomorphicNumber(376)).toBe(true) |
| 26 | + }) |
| 27 | + |
| 28 | + test('2 is NOT automorphic (2² = 4)', () => { |
| 29 | + expect(isAutomorphicNumber(2)).toBe(false) |
| 30 | + }) |
| 31 | + |
| 32 | + test('7 is NOT automorphic (7² = 49)', () => { |
| 33 | + expect(isAutomorphicNumber(7)).toBe(false) |
| 34 | + }) |
| 35 | + |
| 36 | + test('10 is NOT automorphic', () => { |
| 37 | + expect(isAutomorphicNumber(10)).toBe(false) |
| 38 | + }) |
| 39 | + |
| 40 | + test('throws TypeError for zero', () => { |
| 41 | + expect(() => isAutomorphicNumber(0)).toThrow(TypeError) |
9 | 42 | }) |
10 | 43 |
|
11 | | - test.each([ |
12 | | - { n: -3, expected: false }, |
13 | | - { n: -25, expected: false } |
14 | | - ])('should return false when n is negetive', ({ n, expected }) => { |
15 | | - expect(isAutomorphic(n)).toBe(false) |
| 44 | + test('throws TypeError for negative input', () => { |
| 45 | + expect(() => isAutomorphicNumber(-5)).toThrow(TypeError) |
16 | 46 | }) |
17 | 47 |
|
18 | | - test.each([ |
19 | | - { n: 7, expected: false }, |
20 | | - { n: 83, expected: false }, |
21 | | - { n: 0, expected: true }, |
22 | | - { n: 1, expected: true }, |
23 | | - { n: 376, expected: true }, |
24 | | - { n: 90625, expected: true } |
25 | | - ])('should return $expected when n is $n', ({ n, expected }) => { |
26 | | - expect(isAutomorphic(n)).toBe(expected) |
| 48 | + test('throws TypeError for float input', () => { |
| 49 | + expect(() => isAutomorphicNumber(5.5)).toThrow(TypeError) |
27 | 50 | }) |
28 | 51 | }) |
0 commit comments