humanparser is a third-party library we previously used at ParentSquare to parse a human name string into salutation, first name, middle name, last name, and suffix.
- Node version >= v11.15.0
If you have nvm installed you can run nvm use instead
You can use your preferred package manager for the installation
Install using yarn:
yarn installInstall using npm:
npm installYour goal is to find the root cause of the bug described below, then fix it if you have time!
When parseName is called for a salutation and last name only, it is returning the last name as the first name:
const human = require("humanparser")
const attrs = human.parseName("Ms. Smith")
console.log(attrs);actual:
{
salutation: 'Ms.',
firstName: 'Smith',
lastName: '',
fullName: 'Ms. Smith'
}expected:
{
salutation: 'Ms.',
firstName: '',
lastName: 'Smith',
fullName: 'Ms. Smith'
}There are two scripts on the package.json file
test-> will run the tests from thetestfolder using (mocha)[https://mochajs.org/] test suitetest:jest-> will run the tests from thetestfolder using (jest)[https://jestjs.io/docs/en/getting-started] test suite
The mocha test suite has been left untouched for legacy compatibility.
For new tests it's strongly suggested to use the jest test suite