mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-29 18:46:20 -05:00
split password tests up
This commit is contained in:
parent
6bf27b7e8a
commit
7dff707782
1 changed files with 16 additions and 7 deletions
|
@ -24,21 +24,21 @@ describe('unit test lib/validate.js', () => {
|
|||
expect(response).toEqual({valid: false, errMsgId: 'registration.validationUsernameRegexp'});
|
||||
});
|
||||
|
||||
test('validate password', () => {
|
||||
test('validate password existence', () => {
|
||||
let response;
|
||||
expect(typeof validate.validatePassword).toBe('function');
|
||||
response = validate.validatePassword('abcdef');
|
||||
expect(response).toEqual({valid: true});
|
||||
response = validate.validatePassword('abcdefghijklmnopqrst');
|
||||
expect(response).toEqual({valid: true});
|
||||
response = validate.validatePassword('passwo');
|
||||
expect(response).toEqual({valid: true});
|
||||
response = validate.validatePassword('');
|
||||
expect(response).toEqual({valid: false, errMsgId: 'general.required'});
|
||||
});
|
||||
|
||||
test('validate password length', () => {
|
||||
let response;
|
||||
response = validate.validatePassword('abcdefghijklmnopqrst');
|
||||
expect(response).toEqual({valid: true});
|
||||
response = validate.validatePassword('abcde');
|
||||
expect(response).toEqual({valid: false, errMsgId: 'registration.validationPasswordLength'});
|
||||
response = validate.validatePassword('password');
|
||||
expect(response).toEqual({valid: false, errMsgId: 'registration.validationPasswordNotEquals'});
|
||||
response = validate.validatePassword('😺');
|
||||
expect(response).toEqual({valid: false, errMsgId: 'registration.validationPasswordLength'});
|
||||
response = validate.validatePassword('😺🦆🐝');
|
||||
|
@ -47,6 +47,15 @@ describe('unit test lib/validate.js', () => {
|
|||
expect(response).toEqual({valid: false, errMsgId: 'registration.validationPasswordLength'});
|
||||
response = validate.validatePassword('😺🦆🐝🐮🐠🐻');
|
||||
expect(response).toEqual({valid: true});
|
||||
});
|
||||
|
||||
test('validate password cannot be "password"', () => {
|
||||
const response = validate.validatePassword('password');
|
||||
expect(response).toEqual({valid: false, errMsgId: 'registration.validationPasswordNotEquals'});
|
||||
});
|
||||
|
||||
test('validate password cannot be same as username', () => {
|
||||
let response;
|
||||
response = validate.validatePassword('abcdefg', 'abcdefg');
|
||||
expect(response).toEqual({valid: false, errMsgId: 'registration.validationPasswordNotUsername'});
|
||||
response = validate.validatePassword('abcdefg', 'abcdefG');
|
||||
|
|
Loading…
Reference in a new issue