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.
|
|
|
|
|
|
|
|
import {
|
|
|
|
validateProjectName,
|
|
|
|
validatePassword,
|
|
|
|
validateEmail
|
|
|
|
} from '@/utils/validation';
|
|
|
|
|
|
|
|
describe('validation', () => {
|
2019-02-20 13:33:56 +00:00
|
|
|
it('validateProjectName regex works correctly', () => {
|
2019-01-11 10:26:18 +00:00
|
|
|
const testString1 = 'test';
|
|
|
|
const testString2 = ' ';
|
|
|
|
const testString3 = ' test ';
|
|
|
|
const testString4 = ' /test ';
|
|
|
|
const testString5 = ' test213##221344rfvv^ ';
|
|
|
|
const testString6 = '';
|
|
|
|
|
2019-02-20 13:33:56 +00:00
|
|
|
expect(validateProjectName(testString1)).toBe(true);
|
2019-01-11 10:26:18 +00:00
|
|
|
expect(validateProjectName(testString2)).toBe(true);
|
|
|
|
expect(validateProjectName(testString3)).toBe(true);
|
|
|
|
expect(validateProjectName(testString4)).toBe(false);
|
|
|
|
expect(validateProjectName(testString5)).toBe(true);
|
|
|
|
expect(validateProjectName(testString6)).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('validatePassword regex works correctly', () => {
|
|
|
|
const testString1 = 'test';
|
|
|
|
const testString2 = ' ';
|
|
|
|
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);
|
|
|
|
expect(validatePassword(testString3)).toBe(false);
|
|
|
|
expect(validatePassword(testString4)).toBe(false);
|
|
|
|
expect(validatePassword(testString5)).toBe(true);
|
|
|
|
expect(validatePassword(testString6)).toBe(false);
|
|
|
|
expect(validatePassword(testString7)).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
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
|
|
|
});
|