-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathvalidateUtils.test.ts
More file actions
53 lines (47 loc) · 2.16 KB
/
Copy pathvalidateUtils.test.ts
File metadata and controls
53 lines (47 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { validateUtils } from 'src/utils/validateUtils';
type LowerCaseAlphanumericWithSymbolsParams = {
value: string;
symbols?: string;
canSymbolsRepeat?: boolean;
};
suite('validateUtils', () => {
test('isLowerCaseAlphanumericWithSymbols', () => {
const trueValues: LowerCaseAlphanumericWithSymbolsParams[] = [
{ value: 'hello123' },
{ value: 'hello-world' },
{ value: 'hello-world', symbols: '-' },
{ value: 'hello@world', symbols: '@%' },
{ value: 'he!l@l#o', symbols: '!@#' },
{ value: 'hello--world', symbols: '-' },
{ value: 'hello---world', symbols: '-', canSymbolsRepeat: true },
{ value: 'a' },
{ value: '123' },
{ value: '12-3' },
{ value: 'he-ll-o' },
];
for (const { value, symbols, canSymbolsRepeat } of trueValues) {
assert.equal(validateUtils.isLowerCaseAlphanumericWithSymbols(value, symbols, canSymbolsRepeat), true);
}
const falseValues: LowerCaseAlphanumericWithSymbolsParams[] = [
{ value: 'hello_world' },
{ value: 'Hello123' },
{ value: '' },
{ value: 'A' },
{ value: 'hello123-' },
{ value: '-hello123' },
{ value: 'hello--world', symbols: '-', canSymbolsRepeat: false },
{ value: '12.3' },
{ value: '123-8.@9', symbols: '-.' },
{ value: 'he!l@l#o$', symbols: '!@#$' },
{ value: 'he!l@l#$o', symbols: '!@#$', canSymbolsRepeat: false }
];
for (const { value, symbols, canSymbolsRepeat } of falseValues) {
assert.equal(validateUtils.isLowerCaseAlphanumericWithSymbols(value, symbols, canSymbolsRepeat), false);
}
});
});