-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtest.js
53 lines (49 loc) · 840 Bytes
/
test.js
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
'use strict';
const githubUsernameRegex = require('.');
const {strictEqual} = require('assert');
for (const validName of [
'a',
'abc',
'DEF',
'Ghi',
'a-z',
'a-b-c',
'0',
'10',
'1-2',
'abc123',
'abc-123',
'x'.repeat(39)
]) {
strictEqual(
githubUsernameRegex.test(validName),
true,
`Expected "${validName}" to be considiered as a valid Github username, but it wasn't.`
);
}
for (const invalidName of [
'',
' ',
'a b',
'a ',
' b',
'-',
'a-',
'-b',
'a--b',
'a_b',
'a\nb',
'A',
'1',
'あ',
'🍣',
String.fromCharCode(15),
'x'.repeat(40)
]) {
strictEqual(
githubUsernameRegex.test(invalidName),
false,
`Expected ${JSON.stringify(invalidName)} to be considiered as an invalid Github username, but it wasn't.`
);
}
console.log('All tests passed.');