-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added good tests using mocha test framework. Updates on README.
- Loading branch information
1 parent
d945284
commit 62fb713
Showing
3 changed files
with
44 additions
and
11 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,31 @@ | ||
/* | ||
* If you want run tests please install the test framework Mocha (https://mochajs.org). | ||
* Then type the command on the parent folder: mocha test | ||
*/ | ||
|
||
// Require assert mocha | ||
var assert = require('assert'); | ||
|
||
// Require gender detection module | ||
var gender = require('../index.js'); | ||
|
||
// Use it to detect the gender: | ||
g = gender.detect('Tim Johnson'); | ||
console.log(g); | ||
describe('Simple names', function() { | ||
it('It should return male, female, or unknown', function() { | ||
assert.equal('male', gender.detect('John')); | ||
assert.equal('female', gender.detect('Holly')); | ||
}); | ||
}); | ||
|
||
g = gender.detect('Holly'); | ||
console.log(g); | ||
describe('Double names', function() { | ||
it('It should return male, female, or unknown', function() { | ||
assert.equal('male', gender.detect('Tim Johnson')); | ||
assert.equal('female', gender.detect('Francesca Rossi')); | ||
}); | ||
}); | ||
|
||
g = gender.detect('GhJGhgj'); | ||
console.log(g); | ||
describe('Bad formatted names', function() { | ||
it('It should return male, female, or unknown', function() { | ||
assert.equal('male', gender.detect('BiLL$...')); | ||
assert.equal('female', gender.detect('::Jenni♥fer::')); | ||
}); | ||
}); |