|
1 | | -import { checkPalindrome } from '../CheckPalindrome' |
| 1 | +import { checkPalindrome } from '../CheckPalindrome.js' |
2 | 2 |
|
3 | 3 | describe('checkPalindrome', () => { |
4 | | - it('expects to return "Palindrome" if the given string is a palindrome', () => { |
5 | | - const SUT = checkPalindrome('madam') |
6 | | - expect(SUT).toBe('Palindrome') |
| 4 | + test('racecar is a palindrome', () => { |
| 5 | + expect(checkPalindrome('racecar')).toBe(true) |
7 | 6 | }) |
8 | | - it('expects to return "Empty string" if the given string is empty', () => { |
9 | | - const SUT = checkPalindrome('') |
10 | | - expect(SUT).toBe('Empty string') |
| 7 | + |
| 8 | + test('hello is NOT a palindrome', () => { |
| 9 | + expect(checkPalindrome('hello')).toBe(false) |
| 10 | + }) |
| 11 | + |
| 12 | + test('A man a plan a canal Panama is a palindrome', () => { |
| 13 | + expect(checkPalindrome('A man a plan a canal Panama')).toBe(true) |
| 14 | + }) |
| 15 | + |
| 16 | + test('empty string is a palindrome', () => { |
| 17 | + expect(checkPalindrome('')).toBe(true) |
| 18 | + }) |
| 19 | + |
| 20 | + test('single character is a palindrome', () => { |
| 21 | + expect(checkPalindrome('a')).toBe(true) |
11 | 22 | }) |
12 | | - it('expects to return "Not a string" if the given string is not a string', () => { |
13 | | - const SUT = checkPalindrome(123) |
14 | | - expect(SUT).toBe('Not a string') |
| 23 | + |
| 24 | + test('madam is a palindrome', () => { |
| 25 | + expect(checkPalindrome('madam')).toBe(true) |
| 26 | + }) |
| 27 | + |
| 28 | + test('12321 is a palindrome', () => { |
| 29 | + expect(checkPalindrome('12321')).toBe(true) |
| 30 | + }) |
| 31 | + |
| 32 | + test('12345 is NOT a palindrome', () => { |
| 33 | + expect(checkPalindrome('12345')).toBe(false) |
| 34 | + }) |
| 35 | + |
| 36 | + test('throws TypeError for non-string input', () => { |
| 37 | + expect(() => checkPalindrome(123)).toThrow(TypeError) |
15 | 38 | }) |
16 | 39 | }) |
0 commit comments