Example Palindrome Finder Solution
| const palindromes = require('../palindromes'); |
| const { prepareStr, isPalindrome, stringStartPalindrome } = palindromes; |
| |
| describe('prepareStr()', () => { |
| it('converts the given string to lowercase', () => { |
| expect(prepareStr('aAaA')).toBe('aaaa'); |
| }); |
| |
| it('removes all non-letter characters', () => { |
| expect( |
| prepareStr('To infinity, and beyond!') |
| ).toBe('toinfinityandbeyond'); |
| }); |
| }); |
| |
| describe('isPalindrome()', () => { |
| it('returns true when given a palindrome', () => { |
| expect(isPalindrome('aba')).toBe(true); |
| expect(isPalindrome('abba')).toBe(true); |
| }); |
| |
| it('returns false when given a non-palindrome', () => { |
|
Get Test-Driven React now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.