UNPKG

bsmith-palindrome

Version:
42 lines (36 loc) 1.43 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.isPalindrome()); }); it("should return true for a palindrome", function () { let plainPalindrome = new Phrase("racecar"); assert(plainPalindrome.isPalindrome()); }); it("should return true for mixed-case palindrome", function () { let mixedPalindrome = new Phrase("RaceCar"); assert(mixedPalindrome.isPalindrome()); }); it("should return true for palindrome with punctuation", function () { let punctuatedPalindrome = new Phrase("Madam, I'm Adam."); assert(punctuatedPalindrome.isPalindrome()); }); it("should return false for empty string", function () { let emptyPalindrome = new Phrase(""); assert(!emptyPalindrome.isPalindrome()); }); }); describe("#letters", function () { it("should return only letters", function () { let punctuatedPalindrome = new Phrase("Madam, I'm Adam."); assert.strictEqual(punctuatedPalindrome.letters(), "MadamImAdam"); }); it("should return empty string if no letters", function () { let noLetters = new Phrase("1234"); assert.strictEqual(noLetters.letters(), ""); }); }); });