mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-04 07:29:47 +08:00

* 📦 NEW: Added solution for ProjectEuler-007 * 🐛 FIX: Spelling mistake fixes * 👌 IMPROVE: changed variable name from `inc` to `candidateValue` and thrown error in case of invalid input * 👌 IMPROVE: Modified the code * 👌 IMPROVE: Added test case for ProjectEuler Problem001 * 👌 IMPROVE: Added test cases for Project Euler Problem 4 * 👌 IMPROVE: auto prettier fixes --------- Co-authored-by: Omkarnath Parida <omkarnath.parida@yocket.in>
29 lines
832 B
JavaScript
29 lines
832 B
JavaScript
import { isAutomorphic } from '../AutomorphicNumber'
|
|
|
|
describe('AutomorphicNumber', () => {
|
|
it('should throw Error when n is String', () => {
|
|
expect(() => isAutomorphic('qwerty')).toThrow()
|
|
})
|
|
it('should throw Error when n is floating point', () => {
|
|
expect(() => isAutomorphic(13.6)).toThrow()
|
|
})
|
|
|
|
test.each([
|
|
{ n: -3, expected: false },
|
|
{ n: -25, expected: false }
|
|
])('should return false when n is negetive', ({ n, expected }) => {
|
|
expect(isAutomorphic(n)).toBe(false)
|
|
})
|
|
|
|
test.each([
|
|
{ n: 7, expected: false },
|
|
{ n: 83, expected: false },
|
|
{ n: 0, expected: true },
|
|
{ n: 1, expected: true },
|
|
{ n: 376, expected: true },
|
|
{ n: 90625, expected: true }
|
|
])('should return $expected when n is $n', ({ n, expected }) => {
|
|
expect(isAutomorphic(n)).toBe(expected)
|
|
})
|
|
})
|