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 c35fc20
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 43 deletions.
17 changes: 10 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ addons:
packages:
- postgresql-10
- postgresql-client-10
before_script:
- psql -c 'create database testdb;' -U postgres
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
after_script:
- ./cc-test-reporter after-build --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 All @@ -40,3 +33,13 @@ deploy:
app: qcredit
on: develop
after_success: yarn coverage

before_script:
- psql -c 'create database testdb;' -U postgres
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
script:
- yarn test
after_script:
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
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;
});
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"start": "set NODE_ENV=production&node --require @babel/register ./bin/www ",
"devstart": "set NODE_ENV=development&set DEBUG=dev&nodemon --exec babel-node ./bin/www",
"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",
"test": "set NODE_ENV=test&set DEBUG=test&set DBNAME=testdb&nyc --reporter=html --reporter=text --reporter=lcov 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"
},
"bugs": {
"url": "https://github.com/chidimo/Quick-Credit/issues"
Expand Down

0 comments on commit c35fc20

Please sign in to comment.