Last active
October 23, 2019 03:15
-
-
Save alexandreramosdev/439d957e403ec248d2124d407bd9a941 to your computer and use it in GitHub Desktop.
test bcrypt
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
const bcrypt = require('bcryptjs') | |
const User = require('../../app/models/user.model') | |
describe('User', () => { | |
beforeEach(async () => { | |
await User.deleteMany({}) | |
}) | |
it('should encrypt user password', async (done) => { | |
const user = await User.create({ | |
username: 'Alexandre', | |
email: 'alexandre@vulgocode.com', | |
password: '123456' | |
}) | |
const compareHash = await bcrypt.compare('123456', user.password) | |
expect(compareHash).toBe(true) | |
done() | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment