mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-26 09:08:07 -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'});
|
expect(response).toEqual({valid: false, errMsgId: 'registration.validationUsernameRegexp'});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('validate password', () => {
|
test('validate password existence', () => {
|
||||||
let response;
|
let response;
|
||||||
expect(typeof validate.validatePassword).toBe('function');
|
expect(typeof validate.validatePassword).toBe('function');
|
||||||
response = validate.validatePassword('abcdef');
|
response = validate.validatePassword('abcdef');
|
||||||
expect(response).toEqual({valid: true});
|
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('');
|
response = validate.validatePassword('');
|
||||||
expect(response).toEqual({valid: false, errMsgId: 'general.required'});
|
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');
|
response = validate.validatePassword('abcde');
|
||||||
expect(response).toEqual({valid: false, errMsgId: 'registration.validationPasswordLength'});
|
expect(response).toEqual({valid: false, errMsgId: 'registration.validationPasswordLength'});
|
||||||
response = validate.validatePassword('password');
|
|
||||||
expect(response).toEqual({valid: false, errMsgId: 'registration.validationPasswordNotEquals'});
|
|
||||||
response = validate.validatePassword('😺');
|
response = validate.validatePassword('😺');
|
||||||
expect(response).toEqual({valid: false, errMsgId: 'registration.validationPasswordLength'});
|
expect(response).toEqual({valid: false, errMsgId: 'registration.validationPasswordLength'});
|
||||||
response = validate.validatePassword('😺🦆🐝');
|
response = validate.validatePassword('😺🦆🐝');
|
||||||
|
@ -47,6 +47,15 @@ describe('unit test lib/validate.js', () => {
|
||||||
expect(response).toEqual({valid: false, errMsgId: 'registration.validationPasswordLength'});
|
expect(response).toEqual({valid: false, errMsgId: 'registration.validationPasswordLength'});
|
||||||
response = validate.validatePassword('😺🦆🐝🐮🐠🐻');
|
response = validate.validatePassword('😺🦆🐝🐮🐠🐻');
|
||||||
expect(response).toEqual({valid: true});
|
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');
|
response = validate.validatePassword('abcdefg', 'abcdefg');
|
||||||
expect(response).toEqual({valid: false, errMsgId: 'registration.validationPasswordNotUsername'});
|
expect(response).toEqual({valid: false, errMsgId: 'registration.validationPasswordNotUsername'});
|
||||||
response = validate.validatePassword('abcdefg', 'abcdefG');
|
response = validate.validatePassword('abcdefg', 'abcdefG');
|
||||||
|
|
Loading…
Reference in a new issue