Added user passwords

This commit is contained in:
Jori Lallo
2016-09-11 17:47:22 -07:00
parent 43e60aacaf
commit 0e7c216735
5 changed files with 76 additions and 3 deletions

View File

@@ -0,0 +1,22 @@
import { User } from '.';
import { flushdb, sequelize } from '../test/support';
beforeEach(flushdb);
afterAll(() => sequelize.close());
it('should set JWT secret and password digest', async () => {
const user = User.build({
username: 'user',
name: 'User',
email: 'user1@example.com',
password: 'test123!',
});
await user.save();
expect(user.passwordDigest).toBeTruthy();
expect(user.getJwtToken()).toBeTruthy();
expect(await user.verifyPassword('test123!')).toBe(true);
expect(await user.verifyPassword('badPasswd')).toBe(false);
});