Files
JavaScript/Maths/test/Palindrome.test.js
Madhurendra Nath Tiwari 6362cc967a added an algo for checking the string i palindrome or not (#1366)
Co-authored-by: madhuredra <madhuredra.tiwari@zemosolabs.com>
2023-09-23 21:30:10 +05:30

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)
})
})