Skip to content

Commit

Permalink
feat(user): add test on weak password ✅
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreBrisorgueil committed Mar 19, 2019
1 parent 94229e4 commit fbd1e7f
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion modules/users/tests/user.crud.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('User CRUD Unit Tests :', () => {
}
});

test('should be able to register a new user', async () => {
test('should not be able to register a new user with weak password', async () => {
// Init user edited
_userEdited.username = 'register_new_user';
_userEdited.email = '[email protected]';
Expand Down Expand Up @@ -116,6 +116,25 @@ describe('User CRUD Unit Tests :', () => {
}
});

test('should be able to register a new user', async () => {
// Init user edited
_userEdited.username = 'register_new_user';
_userEdited.email = '[email protected]';
_userEdited.password = 'azerty';

try {
const result = await agent.post('/api/auth/signup')
.send(_userEdited)
.expect(422);
expect(result.body.type).toBe('error');
expect(result.body.message).toBe('schema validation error');
expect(result.body.error.details[0].message).toBe('password Password strength score 0 does not suffice the minimum of 3');
} catch (err) {
console.log(err);
expect(err).toBeFalsy();
}
});

test('should not be able to login with wrong email', async () => {
try {
const result = await agent.post('/api/auth/signin')
Expand Down

0 comments on commit fbd1e7f

Please sign in to comment.