-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(improve test coverage): improves the test coverage [Finishes 16…
…7815352]
- Loading branch information
1 parent
dc1dba9
commit feafe4c
Showing
8 changed files
with
242 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { expect } from './test-setup'; | ||
import Util from '../src/helpers/util'; | ||
|
||
const util = new Util(); | ||
describe('util', () => { | ||
it('should return success json object', () => { | ||
util.setSuccess(200, 'success', { data: 'success' }); | ||
const res = { | ||
status: 200, | ||
message: 'hahaha', | ||
data: 'hahah' | ||
}; | ||
expect(res).to.have.deep.property('status'); | ||
expect(res).to.have.deep.property('message'); | ||
expect(res).to.have.deep.property('data'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import 'dotenv/config'; | ||
import { chai, server, expect } from './test-setup'; | ||
import Helper from '../src/helpers/helper'; | ||
import createUser from '../src/services/user.service'; | ||
import sendEmail from '../src/helpers/verification-email'; | ||
import db from '../src/models'; | ||
|
||
const user = { | ||
firstname: 'habineza', | ||
lastname: 'christian', | ||
email: 'habinezadalvan@gmail.com', | ||
password: 'ASqw12345', | ||
username: 'habinezadalvan' | ||
}; | ||
describe('Users', () => { | ||
before(async () => { | ||
await createUser.addUser(user); | ||
}); | ||
after(async () => { | ||
await db.user.destroy({ | ||
where: { email: 'habinezadalvan@gmail.com' } | ||
}); | ||
}); | ||
const token = Helper.generateToken({ | ||
email: 'habinezadalvan@gmail.com', | ||
role: 'normal', | ||
verified: 'false' | ||
}); | ||
|
||
it('should verify email', (done) => { | ||
chai | ||
.request(server) | ||
.get(`/api/v1/users/verify?token=${token}`) | ||
.end((error, res) => { | ||
expect(res.status).to.be.equal(200); | ||
expect(res.body).to.have.deep.property('message'); | ||
done(); | ||
}); | ||
}); | ||
it('should send email from controller', (done) => { | ||
const url = `/api/v1/users/verify?token=${token}`; | ||
sendEmail(user.email, user.username, url); | ||
done(); | ||
}); | ||
it('should catch an error when token is not verified', (done) => { | ||
const results = Helper.verifyToken(); | ||
expect(results).to.equal('jwt must be provided'); | ||
done(); | ||
}); | ||
}); |