Added user passwords
This commit is contained in:
22
server/models/User.test.js
Normal file
22
server/models/User.test.js
Normal 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);
|
||||
});
|
||||
Reference in New Issue
Block a user