UNPKG

swg01-palindrome

Version:
47 lines (37 loc) 1.5 kB
let assert = require("assert"); let Phrase = require("../index.js"); describe("Phrase", function() { describe("#palindrome", function() { it ("Should return false for a non-palindrome", function() { let nonPalindrome = new Phrase("apple"); assert(!nonPalindrome.palindrome()); }); it ("Should return true for a plain palindrome", function() { let plainPalindrome = new Phrase("racecar"); assert(plainPalindrome.palindrome()); }); it("Should return true for a mixed case palindrome", function() { let mixedPalindrome = new Phrase("Racecar"); assert(mixedPalindrome.palindrome()); }); it("Should return true for a palindrome with punctuation", function() { let punctuatedPalindrome = new Phrase("Madam, I'm Adam"); assert(punctuatedPalindrome.palindrome()); }); it("Should return false for an empty string", function() { let emptyPalindrome = new Phrase(""); assert(!emptyPalindrome.palindrome()); }); }); describe("#letters", function() { it("Should only return lettters", function() { let punctuatedPalindrome = new Phrase("Madam, I'm Adam"); assert.strictEqual("MadamImAdam", punctuatedPalindrome.letters()); //assert.strictEqual(punctuatedPalindrome.letters(), "MadamImAdam"); }); it("Should return the empty string on no match", function() { let noLetters = new Phrase("123321"); assert.strictEqual(noLetters.letters(), ""); }); }); });