Unverified Commit 0d95ad53 authored by Benjamin Wheeler's avatar Benjamin Wheeler Committed by GitHub

Merge pull request #3483 from benjiwheeler/join-flow-usernames-can-have-underscores

revise join flow username validation tests
parents e367950a 24fd824e
const validate = require('../../../src/lib/validate');
describe('unit test lib/validate.js', () => {
test('validate username locally', () => {
test('validate username exists locally', () => {
let response;
expect(typeof validate.validateUsernameLocally).toBe('function');
response = validate.validateUsernameLocally('abc');
expect(response).toEqual({valid: true});
response = validate.validateUsernameLocally('abcdefghijklmnopqrst');
expect(response).toEqual({valid: true});
response = validate.validateUsernameLocally('abc-def-ghi');
expect(response).toEqual({valid: true});
response = validate.validateUsernameLocally('');
expect(response).toEqual({valid: false, errMsgId: 'general.required'});
});
test('validate username length locally', () => {
let response;
response = validate.validateUsernameLocally('abcdefghijklmnopqrst');
expect(response).toEqual({valid: true});
response = validate.validateUsernameLocally('ab');
expect(response).toEqual({valid: false, errMsgId: 'registration.validationUsernameMinLength'});
response = validate.validateUsernameLocally('abcdefghijklmnopqrstu');
expect(response).toEqual({valid: false, errMsgId: 'registration.validationUsernameMaxLength'});
response = validate.validateUsernameLocally('abc def');
});
test('validate username hyphens allowed', () => {
const response = validate.validateUsernameLocally('-abc-def-ghi-');
expect(response).toEqual({valid: true});
});
test('validate username underscores allowed', () => {
const response = validate.validateUsernameLocally('_abc_def_ghi_');
expect(response).toEqual({valid: true});
});
test('validate username spaces not allowed', () => {
const response = validate.validateUsernameLocally('abc def');
expect(response).toEqual({valid: false, errMsgId: 'registration.validationUsernameRegexp'});
});
test('validate username special chars not allowed', () => {
let response;
response = validate.validateUsernameLocally('abc!def');
expect(response).toEqual({valid: false, errMsgId: 'registration.validationUsernameRegexp'});
response = validate.validateUsernameLocally('amiascratcher?');
expect(response).toEqual({valid: false, errMsgId: 'registration.validationUsernameRegexp'});
});
test('validate username unicode chars not allowed', () => {
let response;
response = validate.validateUsernameLocally('abc😄def');
expect(response).toEqual({valid: false, errMsgId: 'registration.validationUsernameRegexp'});
response = validate.validateUsernameLocally('🦆🦆🦆😺😺😺');
expect(response).toEqual({valid: false, errMsgId: 'registration.validationUsernameRegexp'});
});
test('validate password', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment