Sample project or task for a job application for an online money transfer provider.
- Git
- Node v10+
- Visual Studio Code
Clone repository
git clone [email protected]:stormwild/serapay.git
cd serapay
Install dependencies and compile TypeScript files
npm i
npm run build
Run tests
npm test
Sample test output
$ npm test
> [email protected] test /path/to/serapay
> nyc mocha -r ts-node/register src/**/*.spec.ts
Config class
✓ should make successful api calls (1843ms)
✓ should return IConfig when getConfig is invoked
✓ should return ICashIn when cashIn is invoked
✓ should return ICashOutNatural when cashOutNatural is invoked
✓ should return ICashOutJuridical when cashOutJuridical is invoked
Serapay class
✓ should return expected output when getCommissions is invoked with test data
6 passing (3s)
------------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
------------|----------|----------|----------|----------|-------------------|
All files | 97.37 | 78.57 | 96.67 | 96.97 | |
config.ts | 97.67 | 72.73 | 88.89 | 97.06 | 59 |
serapay.ts | 97.18 | 82.35 | 100 | 96.92 | 129,157 |
------------|----------|----------|----------|----------|-------------------|
Link to path
npm link
Run from command line
serapaycli
Sample output
$ serapaycli
Usage: serapaycli [options] <path>
Commandline tool that computes commission fees from cash transactions provided in a .json file
Options:
-V, --version output the version number
-i, --input <string> path to json input file
-h, --help output usage information
Run from build
npm start
Sample output
$ npm start
> [email protected] start /Users/stormwild/Source/paysera/cliapp/serapay
> node ./dist/serapaycli.js
Please provide a path to an input file!
Build the application
npm i
npm run build
npm link
Run with the sample data. Make sure you are within the application root folder
serapaycli ./data/input.json
Output
0.06
0.90
87.00
3.00
0.30
0.30
5.00
0.00
0.00
0.00
0.30
Build the application
npm run build
Run with sample data
npm run start ./data/input.json
Alternatively
node ./dist/serapaycli.js ./data/input.json
Output
0.06
0.90
87.00
3.00
0.30
0.30
5.00
0.00
0.00
0.00
0.30
- Additional test data added
- Refactor code
- Correct commission returned
- Unit test added for Serapay class
- All tests passing
Computation seems to be working correctly
- Completed unit test for Config class which wraps config api
- Started command line setup
- Created class as a wrapper for the commission configuration api.