Created
May 7, 2015 16:36
-
-
Save edprince/94c6727d7f8a61bcf72f 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 assert = require('assert'); | |
function validateEmail(email) { | |
var regex = /.*@.*\..*/; | |
if (email.match(regex) !== null) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
describe('Email Validation', function() { | |
describe('Types', function() { | |
it('should be a function', function() { | |
assert.equal(typeof validateEmail, 'function'); | |
}); | |
it('should return a boolean', function() { | |
assert.equal(validateEmail('test', 'boolean')); | |
}); | |
}); | |
describe('Valid', function() { | |
var emails = ['[email protected]', '[email protected]']; | |
emails.forEach(function(email) { | |
it('should return true', function() { | |
assert.equal(validateEmail(email), true); | |
}); | |
}); | |
}); | |
describe('Invalid', function() { | |
var emails = ['danlol.com', 'ed/haha.com']; | |
emails.forEach(function(email) { | |
it('should return false', function() { | |
assert.equal(validateEmail(email), false); | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment