Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions __tests__/api/disburse_loan.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const frisby = require ('../../test_config.js');
const Joi = frisby.Joi;

it ('POST should return a status of 200 OK', function (res) {
return frisby
.put('http://localhost:3000/loans/disburse/5b3c114131124a0d7415c640', {
amountDisbursed: 3500000 ,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you posting amount disbursed and error message while disbursing the loan. If yes, Why ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The amount disbursed is to be posted by the admin. Peradventure, the total amount of loan requested cannot be disbursed a note is attached to disclose why the entire loan cannot be disbursed. The note will be null if all the amount is been disbursed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not an error message. It is a short note attached to explain why all the loan cannot be disbursed

amountDisbursedReason: 'Insufficient fund'
})
.expect('status', 200)
.expect('json', 'status', true)
.expect('jsonTypes', 'payload.*', {
"amount": Joi.number().required(),
"tenure": Joi.number().required(),
"guarantorApproved": Joi.boolean().required(),
"amountDisbursed": Joi.number().required(),
"isApplication": Joi.boolean().required(),
"isApproved": Joi.boolean().required(),
"isDisbursed": Joi.boolean().required(),
"isRepaid": Joi.boolean().required(),
"amountDisbursedReason": Joi.string().required(),

})
.inspectJSON()
.done(res)
})

it ('POST should return a status of 403 OK', function (res){
return frisby
.put('http://localhost:3000/loans/disburse/5b3c1ad36f33bf2e983d257e', {
amountDisbursed: 3500000 ,
amountDisbursedReason: 'Insufficient fund'
})
.expect('status', 403)
.inspectJSON()
.done(res)
})
Loading