Skip to content

Commit

Permalink
feature(endpoint):fetch all dormant accounts
Browse files Browse the repository at this point in the history
Create endpoint for admins to get all dormant accounts

[Finishes #165448156]
  • Loading branch information
tolulope-od committed Apr 20, 2019
1 parent ac52352 commit 2972be1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/validation/accountValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ export default class AccountValidation {
});
}

if (req.query.status !== 'active') {
const { status } = req.query;

if (status !== 'active' && status !== 'dormant') {
return res.status(400).json({
status: 400,
error: 'Account status must be either active or dormant'
Expand Down
15 changes: 15 additions & 0 deletions test/account.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,21 @@ describe('Account Route', () => {
});
});

it('Should fetch all dormant accounts under the bank for an authorized staff', done => {
chai
.request(app)
.get(`${API_PREFIX}/accounts?status=dormant`)
.set('Authorization', staffAuthToken)
.end((err, res) => {
expect(res.body)
.to.have.property('status')
.eql(200);
expect(res.body).to.have.property('data');
expect(res.status).to.equal(200);
done();
});
});

it('Should not fetch accounts by their status if a user requests it', done => {
chai
.request(app)
Expand Down

0 comments on commit 2972be1

Please sign in to comment.