mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-18 01:05:42 +08:00
26 lines
908 B
JavaScript
26 lines
908 B
JavaScript
import { PalindromeRecursive, PalindromeIterative, checkPalindrome } from '../Palindrome'
|
|
|
|
describe('Palindrome', () => {
|
|
it('should return true for a palindrome for PalindromeRecursive', () => {
|
|
expect(PalindromeRecursive('mom')).toBeTruthy()
|
|
})
|
|
it('should return true for a palindrome for PalindromeIterative', () => {
|
|
expect(PalindromeIterative('mom')).toBeTruthy()
|
|
})
|
|
it('should return false for a non-palindrome for PalindromeRecursive', () => {
|
|
expect(PalindromeRecursive('Algorithms')).toBeFalsy()
|
|
})
|
|
it('should return true for a non-palindrome for PalindromeIterative', () => {
|
|
expect(PalindromeIterative('JavaScript')).toBeFalsy()
|
|
})
|
|
|
|
it.each([
|
|
['radar', true],
|
|
['hello', false],
|
|
['r', true],
|
|
[' racecar ', true]
|
|
])('should return value is palindrome or not', (value, expected) => {
|
|
expect(checkPalindrome(value)).toBe(expected)
|
|
})
|
|
})
|