Skip to content

Instantly share code, notes, and snippets.

@alexandreramosdev
Last active October 23, 2019 03:15
Show Gist options
  • Save alexandreramosdev/439d957e403ec248d2124d407bd9a941 to your computer and use it in GitHub Desktop.
Save alexandreramosdev/439d957e403ec248d2124d407bd9a941 to your computer and use it in GitHub Desktop.
test bcrypt
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