Files
JavaScript/Maths/test/isPalindromeIntegerNumber.test.js
Changi Cho 45f0b7cae6 algorithm: check if integer is palindrome (#1177)
* feat: Add check number case

* style: Fix formatting

* fix: Remove number check part

* feat: Create isPalindromeIntegerNumber

* test: Add minus number case
2022-10-15 14:44:44 +05:30

33 lines
1.2 KiB
JavaScript

import { isPalindromeIntegerNumber } from '../isPalindromeIntegerNumber'
describe('isPalindromeIntegerNumber', () => {
it('expects to return true when length of input is 1', () => {
expect(isPalindromeIntegerNumber(6)).toEqual(true)
})
it('expects to return true when input is palindrome', () => {
expect(isPalindromeIntegerNumber(121)).toEqual(true)
expect(isPalindromeIntegerNumber(12321)).toEqual(true)
expect(isPalindromeIntegerNumber(1221)).toEqual(true)
})
it('expects to return false when input is not palindrome', () => {
expect(isPalindromeIntegerNumber(189)).toEqual(false)
})
it('expects to return false when input is minus', () => {
expect(isPalindromeIntegerNumber(-121)).toEqual(false)
expect(isPalindromeIntegerNumber(-12321)).toEqual(false)
})
it('expects to return false when input is not integer number', () => {
expect(isPalindromeIntegerNumber(123.456)).toEqual(false)
})
it('expects to throw error when input is not a number', () => {
expect(() => isPalindromeIntegerNumber(undefined)).toThrowError()
expect(() => isPalindromeIntegerNumber({ key: 'val' })).toThrowError()
expect(() => isPalindromeIntegerNumber([])).toThrowError()
})
})