2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2019-01-11 10:26:18 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2020-06-02 15:08:20 +01:00
|
|
|
import { Validator } from '@/utils/validation';
|
2019-01-11 10:26:18 +00:00
|
|
|
|
2020-06-02 15:08:20 +01:00
|
|
|
describe('validation', (): void => {
|
|
|
|
it('password regex works correctly', (): void => {
|
2019-01-11 10:26:18 +00:00
|
|
|
const testString1 = 'test';
|
2019-08-22 17:03:13 +01:00
|
|
|
const testString2 = ' '.trim();
|
2019-01-11 10:26:18 +00:00
|
|
|
const testString3 = 'test %%%';
|
|
|
|
const testString4 = 'testtest';
|
|
|
|
const testString5 = 'test1233';
|
|
|
|
const testString6 = 'test1';
|
|
|
|
const testString7 = 'teSTt1123';
|
|
|
|
|
2020-06-02 15:08:20 +01:00
|
|
|
expect(Validator.password(testString1)).toBe(false);
|
|
|
|
expect(Validator.password(testString2)).toBe(false);
|
|
|
|
expect(Validator.password(testString3)).toBe(true);
|
|
|
|
expect(Validator.password(testString4)).toBe(true);
|
|
|
|
expect(Validator.password(testString5)).toBe(true);
|
|
|
|
expect(Validator.password(testString6)).toBe(false);
|
|
|
|
expect(Validator.password(testString7)).toBe(true);
|
2019-01-11 10:26:18 +00:00
|
|
|
});
|
2019-09-13 10:48:27 +01:00
|
|
|
|
2020-06-02 15:08:20 +01:00
|
|
|
it('email regex works correctly', () => {
|
2019-01-11 10:26:18 +00:00
|
|
|
const testString1 = 'test';
|
|
|
|
const testString2 = ' ';
|
|
|
|
const testString3 = 'test@';
|
|
|
|
const testString4 = 'test.test';
|
|
|
|
const testString5 = 'test1@23.3';
|
|
|
|
const testString6 = '';
|
|
|
|
const testString7 = '@teSTt.1123';
|
|
|
|
|
2020-06-02 15:08:20 +01:00
|
|
|
expect(Validator.email(testString1)).toBe(false);
|
|
|
|
expect(Validator.email(testString2)).toBe(false);
|
|
|
|
expect(Validator.email(testString3)).toBe(false);
|
|
|
|
expect(Validator.email(testString4)).toBe(false);
|
|
|
|
expect(Validator.email(testString5)).toBe(true);
|
|
|
|
expect(Validator.email(testString6)).toBe(false);
|
|
|
|
expect(Validator.email(testString7)).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('anyCharactersButSlash regex works correctly', () => {
|
|
|
|
const testString1 = 'tGDFst/';
|
|
|
|
const testString2 = '/ ';
|
|
|
|
const testString3 = 'tes/t@';
|
|
|
|
const testString4 = 'test./test';
|
|
|
|
const testString5 = '3gGD!@#$%^&*()-=+.,';
|
|
|
|
const testString6 = ' /';
|
|
|
|
const testString7 = '/teSTt1123';
|
|
|
|
|
|
|
|
expect(Validator.anyCharactersButSlash(testString1)).toBe(false);
|
|
|
|
expect(Validator.anyCharactersButSlash(testString2)).toBe(false);
|
|
|
|
expect(Validator.anyCharactersButSlash(testString3)).toBe(false);
|
|
|
|
expect(Validator.anyCharactersButSlash(testString4)).toBe(false);
|
|
|
|
expect(Validator.anyCharactersButSlash(testString5)).toBe(true);
|
|
|
|
expect(Validator.anyCharactersButSlash(testString6)).toBe(false);
|
|
|
|
expect(Validator.anyCharactersButSlash(testString7)).toBe(false);
|
2019-02-20 13:33:56 +00:00
|
|
|
});
|
2019-01-11 10:26:18 +00:00
|
|
|
});
|