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.
|
|
|
|
|
2019-03-29 10:46:42 +00:00
|
|
|
import {
|
2019-09-09 11:33:39 +01:00
|
|
|
validateEmail,
|
|
|
|
validatePassword
|
2019-01-11 10:26:18 +00:00
|
|
|
} from '@/utils/validation';
|
|
|
|
|
|
|
|
describe('validation', () => {
|
|
|
|
it('validatePassword regex works correctly', () => {
|
|
|
|
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';
|
|
|
|
|
|
|
|
expect(validatePassword(testString1)).toBe(false);
|
|
|
|
expect(validatePassword(testString2)).toBe(false);
|
2019-08-22 17:03:13 +01:00
|
|
|
expect(validatePassword(testString3)).toBe(true);
|
|
|
|
expect(validatePassword(testString4)).toBe(true);
|
2019-01-11 10:26:18 +00:00
|
|
|
expect(validatePassword(testString5)).toBe(true);
|
|
|
|
expect(validatePassword(testString6)).toBe(false);
|
|
|
|
expect(validatePassword(testString7)).toBe(true);
|
|
|
|
});
|
2019-09-13 10:48:27 +01:00
|
|
|
|
2019-01-11 10:26:18 +00:00
|
|
|
it('validateEmail regex works correctly', () => {
|
|
|
|
const testString1 = 'test';
|
|
|
|
const testString2 = ' ';
|
|
|
|
const testString3 = 'test@';
|
|
|
|
const testString4 = 'test.test';
|
|
|
|
const testString5 = 'test1@23.3';
|
|
|
|
const testString6 = '';
|
|
|
|
const testString7 = '@teSTt.1123';
|
|
|
|
|
|
|
|
expect(validateEmail(testString1)).toBe(false);
|
|
|
|
expect(validateEmail(testString2)).toBe(false);
|
|
|
|
expect(validateEmail(testString3)).toBe(false);
|
|
|
|
expect(validateEmail(testString4)).toBe(false);
|
|
|
|
expect(validateEmail(testString5)).toBe(true);
|
|
|
|
expect(validateEmail(testString6)).toBe(false);
|
|
|
|
expect(validateEmail(testString7)).toBe(true);
|
2019-02-20 13:33:56 +00:00
|
|
|
});
|
2019-01-11 10:26:18 +00:00
|
|
|
});
|