Skip to content

Instantly share code, notes, and snippets.

@davidgilbertson
Last active September 25, 2016 22:02
Show Gist options
  • Save davidgilbertson/29e0dab9140df07d534639e8fa073f73 to your computer and use it in GitHub Desktop.
Save davidgilbertson/29e0dab9140df07d534639e8fa073f73 to your computer and use it in GitHub Desktop.
const testInputs = [
// correct
{firstName: '', lastName: '', email: '[email protected]', expectedResult: ''},
{firstName: 'yo', lastName: 'shortname', email: '[email protected]', expectedResult: ''},
{firstName: 'david', lastName: 'gilbertson', email: '[email protected]', expectedResult: ''},
{firstName: 'david', lastName: 'gilbertson', email: 'david.gilbertson@SOME+THING-ODD!!.com', expectedResult: ''},
{firstName: 'david', lastName: 'gilbertson', email: '[email protected]', expectedResult: ''},
{firstName: 'david', lastName: 'gilbertson', email: '[email protected]', expectedResult: ''},
{firstName: 'david', lastName: 'gilbertson', email: '[email protected]', expectedResult: ''},
{firstName: 'david', lastName: 'gilbertson', email: '[email protected]', expectedResult: ''},
{firstName: 'david', lastName: 'gilbertson', email: '[email protected]', expectedResult: ''},
// common mistakes
{firstName: 'a', lastName: 'b', email: 'a.b@example,com', expectedResult: '[email protected]'},
{firstName: 'a', lastName: 'b', email: 'a.b@example,co.de', expectedResult: '[email protected]'},
{firstName: 'a', lastName: 'b', email: 'a.b@noDotCom', expectedResult: '[email protected]'},
// domain typo
{firstName: 'david', lastName: 'gilbertson', email: '[email protected]', expectedResult: '[email protected]'},
{firstName: 'david', lastName: 'gilbertson', email: '[email protected]', expectedResult: '[email protected]'},
{firstName: 'david', lastName: 'gilbertson', email: '[email protected]', expectedResult: '[email protected]'},
{firstName: 'david', lastName: 'gilbertson', email: '[email protected]', expectedResult: '[email protected]'},
{firstName: 'david', lastName: 'gilbertson', email: '[email protected]', expectedResult: '[email protected]'},
// name typo
{firstName: 'david', lastName: 'gilbertson', email: '[email protected]', expectedResult: '[email protected]'},
{firstName: 'david', lastName: 'gilbertson', email: '[email protected]', expectedResult: '[email protected]'},
{firstName: 'david', lastName: 'gilbertson', email: '[email protected]', expectedResult: '[email protected]'},
{firstName: 'david', lastName: 'gilbertson', email: '[email protected]', expectedResult: '[email protected]'},
{firstName: 'david', lastName: 'gilbertson', email: '[email protected]', expectedResult: '[email protected]'},
{firstName: 'david', lastName: 'gilbertson', email: '[email protected]', expectedResult: '[email protected]'},
];
testInputs.forEach(testInput => {
console.assert(
testInput.expectedResult === checkForTypo(testInput),
`${testInput.email} was not given the suggestion: ${testInput.expectedResult}`
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment