Last active
July 2, 2016 12:22
-
-
Save greghelton/3ba87c58d27f7ad95c7da146d4fe8d75 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var expect = require('chai').expect; | |
var isPalindrome = require('../src/ispalindrome'); | |
describe('palindrome-test', function() { | |
it('should pass this canary test', function() { | |
expect(true).to.be.true; | |
}); | |
it('should return true for argument mom', function() { | |
expect(isPalindrome('mom')).to.be.true; | |
}); | |
it('should return true for argument dad', function() { | |
expect(isPalindrome('dad')).to.be.true; | |
}); | |
it('should return false for argument dude', function() { | |
expect(isPalindrome('dude')).to.be.false; | |
}); | |
it ('should throw an exception when argument is missing', function() { | |
var call = function() { isPalindrome() } | |
expect(call).to.throw(Error, 'Invalid Argument'); | |
}); | |
it('should return true for argument mom mom', function() { | |
expect(isPalindrome('mom mom')).to.be.true; | |
}); | |
it('should return false for argument mom dad', function() { | |
expect(isPalindrome('mom dad')).to.be.false; | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(phrase) { | |
if (phrase === undefined) { | |
throw new Error('Invalid Argument'); | |
} | |
return phrase.trim().length > 0 && | |
phrase.split('').reverse().join('') === phrase; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "palindrome", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"directories": { | |
"test": "test" | |
}, | |
"scripts": { | |
"test": "mocha test", | |
"node": "node_modules/istanbul/lib/cli.js cover node_modules/mocha/bin/_mocha" | |
}, | |
"author": "Greg Helton", | |
"license": "ISC", | |
"devDependencies": { | |
"chai": "^3.5.0", | |
"istanbul": "^0.4.2", | |
"mocha": "^2.4.5" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment