Skip to content

Commit

Permalink
chore(UI js): improve code coverage
Browse files Browse the repository at this point in the history
- configure codeclimate reporting
  • Loading branch information
chidimo committed May 21, 2019
1 parent 94751f8 commit 2f66c5a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ before_script:
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
after_script:
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
- ./cc-test-reporter after-build -t lcov --exit-code $TRAVIS_TEST_RESULT
before_install:
- sudo sed -i -e '/local.*peer/s/postgres/all/' -e 's/peer\|md5/trust/g' /etc/postgresql/*/main/pg_hba.conf
- sudo service postgresql restart
Expand Down
31 changes: 15 additions & 16 deletions UI/js/loan.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,30 @@ const reject_loan_application = document.getElementById(
'reject_loan_application'
);

approve_loan_application.addEventListener('click', e => {
e.preventDefault();
const cont = prompt(
'Confirm loan approval',
'Click okay to approve this loan request');

const promptUser = (text, defaultText, msg) => {
const cont = prompt(text, defaultText);
if (cont !== null) {
alert('Loan application was approved');
// send email notification
alert(msg);
}
};

approve_loan_application.addEventListener('click', e => {
e.preventDefault();
promptUser(
'Confirm loan approval',
'Click okay to approve this loan request',
'Loan application was approved'
);
return;
});

reject_loan_application.addEventListener('click', e => {
e.preventDefault();
const cont = prompt(
promptUser(
'Confirm loan rejection',
'Click okay to reject this loan request');

if (cont !== null) {
alert('Loan application was rejected');
// send email notification
}

'Click okay to reject this loan request',
'Loan application was rejected'
);
return;
});

Expand Down
35 changes: 17 additions & 18 deletions UI/js/user.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
const verify_user = document.getElementById('verify_user');
const un_verify_user = document.getElementById('un_verify_user');

verify_user.addEventListener('click', e => {
e.preventDefault();
const cont = prompt(
'Please confirm if you want to verify this user',
'Click okay to reject this loan request');

const promptUser = (text, defaultText, msg) => {
const cont = prompt(text, defaultText);
if (cont !== null) {
// verify user
alert('User was verified.');
// Send email notification
alert(msg);
}
};

verify_user.addEventListener('click', e => {
e.preventDefault();

promptUser(
'Confirm user verification',
'Click okay to verify this user',
'User was verified.'
);
return;
});

un_verify_user.addEventListener('click', e => {
e.preventDefault();
const cont = prompt(
"Please confirm if you want to verify revoke this user's verification",
"Click okay to revoke this user's verification");

if (cont !== null) {
// revoke verification
alert("User's verification was revoked.");
// Send email notification
}

promptUser(
'Confirm revoking user verification',
"Click okay to revoke this user's verification",
"User's verification was revoked."
);
return;
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"lint": "./node_modules/.bin/eslint ./",
"test": "set NODE_ENV=test&set DEBUG=test&set DBNAME=testdb&nyc --reporter=html --reporter=text mocha -r @babel/register -r should",
"cover": "nyc report --reporter=text-lcov | coveralls",
"coverage": "nyc report --reporter=text-lcov | coveralls && rm -rf ./.nyc_output && rm -rf coverage/"
"coverage": "nyc report --reporter=text-lcov | coveralls && rm -rf ./.nyc_output"
},
"bugs": {
"url": "https://github.com/chidimo/Quick-Credit/issues"
Expand Down

0 comments on commit 2f66c5a

Please sign in to comment.