randex 1.1.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +1 -1
- package/README.md +20 -0
- package/eslint.config.js +29 -0
- package/lib/basic/set.js +48 -51
- package/lib/basic/type.js +27 -34
- package/lib/custom/bool.js +1 -2
- package/lib/custom/email.js +8 -9
- package/lib/custom/filenameX.js +7 -8
- package/lib/custom/fullnameX.js +7 -8
- package/lib/custom/index.d.ts +10 -8
- package/lib/custom/index.js +64 -45
- package/lib/custom/number.js +11 -12
- package/lib/custom/phrase.js +11 -12
- package/lib/custom/random.js +23 -29
- package/lib/custom/sentence.js +13 -14
- package/lib/custom/singleName.js +7 -8
- package/lib/custom/username.js +6 -7
- package/lib/custom/word.js +9 -10
- package/lib/index.js +1 -2
- package/lib/test/array.test.js +10 -13
- package/lib/test/arrayItem.test.js +17 -0
- package/lib/test/email.test.js +35 -35
- package/lib/test/filename.test.js +38 -38
- package/lib/test/fullname.test.js +7 -7
- package/lib/test/markdown.test.js +14 -14
- package/lib/test/name.test.js +13 -13
- package/lib/test/number.many.test.js +21 -24
- package/lib/test/number.test.js +26 -27
- package/lib/test/params.test.js +51 -51
- package/lib/test/phrase.test.js +22 -22
- package/lib/test/random.test.js +36 -38
- package/lib/test/sentence.test.js +22 -22
- package/lib/test/{set-util.test.js → setUtil.test.js} +7 -7
- package/lib/test/shuffle.test.d.ts +1 -0
- package/lib/test/shuffle.test.js +14 -0
- package/lib/test/spreader.test.js +13 -12
- package/lib/test/testUtil.js +121 -0
- package/lib/test/type.test.js +11 -14
- package/lib/test/username.test.js +11 -11
- package/lib/test/word.test.js +16 -16
- package/lib/utils/spreader.d.ts +1 -0
- package/lib/utils/spreader.js +19 -25
- package/package.json +4 -4
- package/.eslintignore +0 -3
- package/.eslintrc.js +0 -3
- package/lib/test/array-item.test.js +0 -18
- package/lib/test/test-util.js +0 -134
- /package/lib/test/{array-item.test.d.ts → arrayItem.test.d.ts} +0 -0
- /package/lib/test/{set-util.test.d.ts → setUtil.test.d.ts} +0 -0
- /package/lib/test/{test-util.d.ts → testUtil.d.ts} +0 -0
package/lib/custom/phrase.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
exports.randexPhrase = randexPhrase;
|
|
4
|
+
exports.randexManyPhrase = randexManyPhrase;
|
|
5
|
+
const const_1 = require("../basic/const");
|
|
6
|
+
const set_1 = require("../basic/set");
|
|
7
|
+
const type_1 = require("../basic/type");
|
|
8
|
+
const word_1 = require("./word");
|
|
8
9
|
function randexPhrase(p1, p2) {
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
let length = const_1.DEFAULT_PHRASE_RANGE;
|
|
11
|
+
let alphabet = "english";
|
|
11
12
|
if (type_1.RandexTypeParser.isLength(p1)) {
|
|
12
13
|
length = p1;
|
|
13
14
|
}
|
|
@@ -18,7 +19,7 @@ function randexPhrase(p1, p2) {
|
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
else if (typeof p1 === "object") {
|
|
21
|
-
|
|
22
|
+
const options = p1;
|
|
22
23
|
if (options.alphabet) {
|
|
23
24
|
alphabet = options.alphabet;
|
|
24
25
|
}
|
|
@@ -26,14 +27,12 @@ function randexPhrase(p1, p2) {
|
|
|
26
27
|
length = options.words;
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
+
const words = (0, word_1.randexManyWord)(length)(alphabet);
|
|
30
31
|
return words.join(" ");
|
|
31
32
|
}
|
|
32
|
-
exports.randexPhrase = randexPhrase;
|
|
33
33
|
function randexManyPhrase(count) {
|
|
34
34
|
function many(p1, p2) {
|
|
35
|
-
return set_1.RandexSetUtil.many(count,
|
|
35
|
+
return set_1.RandexSetUtil.many(count, () => randexPhrase(p1, p2));
|
|
36
36
|
}
|
|
37
37
|
return many;
|
|
38
38
|
}
|
|
39
|
-
exports.randexManyPhrase = randexManyPhrase;
|
package/lib/custom/random.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.randexRandom =
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
exports.randexRandom = randexRandom;
|
|
4
|
+
const set_1 = require("../basic/set");
|
|
5
|
+
const type_1 = require("../basic/type");
|
|
6
6
|
function randomString(params) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const { length, range } = params;
|
|
8
|
+
let result = "";
|
|
9
|
+
let currentLength = 0;
|
|
10
10
|
if (typeof length === "number") {
|
|
11
11
|
currentLength = length;
|
|
12
12
|
}
|
|
13
13
|
else if (Array.isArray(length)) {
|
|
14
|
-
|
|
14
|
+
const [min, max] = length;
|
|
15
15
|
currentLength = set_1.RandexSetUtil.randomRangeNumber(min, max);
|
|
16
16
|
}
|
|
17
|
-
for (
|
|
18
|
-
|
|
17
|
+
for (let i = 0; i < currentLength; i++) {
|
|
18
|
+
const index = set_1.RandexSetUtil.randomSingleNumber(range.length - 1);
|
|
19
19
|
if (range.length >= index || range.length <= index) {
|
|
20
20
|
result += range[index];
|
|
21
21
|
}
|
|
@@ -30,31 +30,31 @@ function toContent(options) {
|
|
|
30
30
|
}
|
|
31
31
|
else if (type_1.RandexTypeParser.isPartArray(options)) {
|
|
32
32
|
if (options.length === 2) {
|
|
33
|
-
|
|
33
|
+
const [set, rangeOrLength] = options;
|
|
34
34
|
return type_1.RandexTypeParser.isLength(rangeOrLength)
|
|
35
35
|
? {
|
|
36
|
-
set
|
|
36
|
+
set,
|
|
37
37
|
length: rangeOrLength,
|
|
38
38
|
}
|
|
39
39
|
: {
|
|
40
|
-
set
|
|
40
|
+
set,
|
|
41
41
|
charRange: rangeOrLength,
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
else if (options.length === 3) {
|
|
45
|
-
|
|
45
|
+
const [set, range, length] = options;
|
|
46
46
|
return {
|
|
47
|
-
set
|
|
47
|
+
set,
|
|
48
48
|
charRange: range,
|
|
49
|
-
length
|
|
49
|
+
length,
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
return options;
|
|
54
54
|
}
|
|
55
55
|
function toRangeOptions(options) {
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
let fullRange = "";
|
|
57
|
+
const { set, charRange: range, length = 1 } = options;
|
|
58
58
|
if (range) {
|
|
59
59
|
fullRange += range;
|
|
60
60
|
}
|
|
@@ -63,21 +63,15 @@ function toRangeOptions(options) {
|
|
|
63
63
|
}
|
|
64
64
|
return {
|
|
65
65
|
range: fullRange,
|
|
66
|
-
length
|
|
66
|
+
length,
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
|
-
function randexRandom() {
|
|
70
|
-
|
|
71
|
-
for (
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
var result = "";
|
|
75
|
-
for (var _a = 0, options_1 = options; _a < options_1.length; _a++) {
|
|
76
|
-
var option = options_1[_a];
|
|
77
|
-
var content = toContent(option);
|
|
78
|
-
var p = toRangeOptions(content);
|
|
69
|
+
function randexRandom(...options) {
|
|
70
|
+
let result = "";
|
|
71
|
+
for (const option of options) {
|
|
72
|
+
const content = toContent(option);
|
|
73
|
+
const p = toRangeOptions(content);
|
|
79
74
|
result += randomString(p);
|
|
80
75
|
}
|
|
81
76
|
return result;
|
|
82
77
|
}
|
|
83
|
-
exports.randexRandom = randexRandom;
|
package/lib/custom/sentence.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
exports.randexSentence = randexSentence;
|
|
4
|
+
exports.randexManySentence = randexManySentence;
|
|
5
|
+
const const_1 = require("../basic/const");
|
|
6
|
+
const set_1 = require("../basic/set");
|
|
7
|
+
const type_1 = require("../basic/type");
|
|
8
|
+
const word_1 = require("./word");
|
|
8
9
|
function randexSentence(p1, p2) {
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
let length = const_1.DEFAULT_SENTENCE_RANGE;
|
|
11
|
+
let alphabet = "english";
|
|
11
12
|
if (type_1.RandexTypeParser.isLength(p1)) {
|
|
12
13
|
length = p1;
|
|
13
14
|
}
|
|
@@ -18,7 +19,7 @@ function randexSentence(p1, p2) {
|
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
else if (typeof p1 === "object") {
|
|
21
|
-
|
|
22
|
+
const options = p1;
|
|
22
23
|
if (options.alphabet) {
|
|
23
24
|
alphabet = options.alphabet;
|
|
24
25
|
}
|
|
@@ -26,10 +27,10 @@ function randexSentence(p1, p2) {
|
|
|
26
27
|
length = options.words;
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
+
const words = (0, word_1.randexManyWord)(length)(alphabet);
|
|
30
31
|
return words
|
|
31
|
-
.map(
|
|
32
|
-
|
|
32
|
+
.map((text, index) => {
|
|
33
|
+
let wordText = text;
|
|
33
34
|
if (index === 0 && text.length > 0) {
|
|
34
35
|
wordText = text[0].toUpperCase() + text.slice(1);
|
|
35
36
|
}
|
|
@@ -40,11 +41,9 @@ function randexSentence(p1, p2) {
|
|
|
40
41
|
})
|
|
41
42
|
.join(" ");
|
|
42
43
|
}
|
|
43
|
-
exports.randexSentence = randexSentence;
|
|
44
44
|
function randexManySentence(count) {
|
|
45
45
|
function many(p1, p2) {
|
|
46
|
-
return set_1.RandexSetUtil.many(count,
|
|
46
|
+
return set_1.RandexSetUtil.many(count, () => randexSentence(p1, p2));
|
|
47
47
|
}
|
|
48
48
|
return many;
|
|
49
49
|
}
|
|
50
|
-
exports.randexManySentence = randexManySentence;
|
package/lib/custom/singleName.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.randexSingleName =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
exports.randexSingleName = randexSingleName;
|
|
4
|
+
const set_1 = require("../basic/set");
|
|
5
|
+
const type_1 = require("../basic/type");
|
|
6
|
+
const random_1 = require("./random");
|
|
7
7
|
function randexSingleName(p1, p2) {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
let length = 0;
|
|
9
|
+
let alphabet = "english";
|
|
10
10
|
if (type_1.RandexTypeParser.isLength(p1)) {
|
|
11
11
|
length = p1;
|
|
12
12
|
}
|
|
@@ -24,7 +24,6 @@ function randexSingleName(p1, p2) {
|
|
|
24
24
|
length = p1.length;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
const currentLength = set_1.RandexSetUtil.getLength(1, length, [1, 9]);
|
|
28
28
|
return (0, random_1.randexRandom)([alphabet, "u"], [[alphabet, "l"], currentLength]);
|
|
29
29
|
}
|
|
30
|
-
exports.randexSingleName = randexSingleName;
|
package/lib/custom/username.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.randexUsername =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
exports.randexUsername = randexUsername;
|
|
4
|
+
const set_1 = require("../basic/set");
|
|
5
|
+
const type_1 = require("../basic/type");
|
|
6
|
+
const random_1 = require("./random");
|
|
7
7
|
function randexUsername(options) {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const length = type_1.RandexTypeParser.isLength(options) ? options : options?.length;
|
|
9
|
+
const currentLength = set_1.RandexSetUtil.getLength(1, length, [6, 10]);
|
|
10
10
|
return (0, random_1.randexRandom)(["english", "l"], [[["english", "l"], "number"], currentLength]);
|
|
11
11
|
}
|
|
12
|
-
exports.randexUsername = randexUsername;
|
package/lib/custom/word.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
exports.randexWord = randexWord;
|
|
4
|
+
exports.randexManyWord = randexManyWord;
|
|
5
|
+
const const_1 = require("../basic/const");
|
|
6
|
+
const set_1 = require("../basic/set");
|
|
7
|
+
const type_1 = require("../basic/type");
|
|
8
|
+
const random_1 = require("./random");
|
|
8
9
|
function randexWord(p1, p2) {
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
let length = const_1.DEFAULT_WORD_RANGE;
|
|
11
|
+
let alphabet = "english";
|
|
11
12
|
if (type_1.RandexTypeParser.isLength(p1)) {
|
|
12
13
|
length = p1;
|
|
13
14
|
}
|
|
@@ -27,11 +28,9 @@ function randexWord(p1, p2) {
|
|
|
27
28
|
}
|
|
28
29
|
return (0, random_1.randexRandom)([[alphabet, "l"], length]);
|
|
29
30
|
}
|
|
30
|
-
exports.randexWord = randexWord;
|
|
31
31
|
function randexManyWord(count) {
|
|
32
32
|
function many(p1, p2) {
|
|
33
|
-
return set_1.RandexSetUtil.many(count,
|
|
33
|
+
return set_1.RandexSetUtil.many(count, () => randexWord(p1, p2));
|
|
34
34
|
}
|
|
35
35
|
return many;
|
|
36
36
|
}
|
|
37
|
-
exports.randexManyWord = randexManyWord;
|
package/lib/index.js
CHANGED
|
@@ -14,9 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
17
|
+
const custom_1 = require("./custom");
|
|
18
18
|
__exportStar(require("./interfaces"), exports);
|
|
19
19
|
__exportStar(require("./custom"), exports);
|
|
20
20
|
__exportStar(require("./utils"), exports);
|
|
21
|
-
// eslint-disable-next-line import/no-default-export
|
|
22
21
|
exports.default = custom_1.Randex;
|
package/lib/test/array.test.js
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
const custom_1 = require("../custom");
|
|
4
4
|
function testUniqueArray(array, count) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
expect(uniqueResult.find(
|
|
5
|
+
const value = custom_1.Randex.array(array, count);
|
|
6
|
+
const uniqueResult = [];
|
|
7
|
+
for (let i = 0; i < count; i++) {
|
|
8
|
+
const uniqueValue = value[i];
|
|
9
|
+
expect(uniqueResult.find(x => x === uniqueValue)).toBeFalsy();
|
|
10
10
|
uniqueResult.push(uniqueValue);
|
|
11
|
-
};
|
|
12
|
-
for (var i = 0; i < count; i++) {
|
|
13
|
-
_loop_1(i);
|
|
14
11
|
}
|
|
15
12
|
}
|
|
16
|
-
describe("randomNumberArray",
|
|
17
|
-
it("param: number",
|
|
13
|
+
describe("randomNumberArray", () => {
|
|
14
|
+
it("param: number", () => {
|
|
18
15
|
testUniqueArray([1, 2, 3, 4, 5, 6], 6);
|
|
19
16
|
});
|
|
20
|
-
it("param: string",
|
|
17
|
+
it("param: string", () => {
|
|
21
18
|
testUniqueArray(["1", "2", "3", "4", "5", "6"], 6);
|
|
22
19
|
});
|
|
23
|
-
it("max count - array count",
|
|
20
|
+
it("max count - array count", () => {
|
|
24
21
|
testUniqueArray([1, 2, 3, 4, 5, 6], 8);
|
|
25
22
|
});
|
|
26
23
|
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const custom_1 = require("../custom");
|
|
4
|
+
const testUtil_1 = require("./testUtil");
|
|
5
|
+
describe("randomArrayItem", () => {
|
|
6
|
+
it("param: number", () => {
|
|
7
|
+
const array = [1, 2, 3, 4, 5, 6];
|
|
8
|
+
const resultArray = {};
|
|
9
|
+
testUtil_1.TestUtil.loop(() => {
|
|
10
|
+
const value = custom_1.Randex.arrayItem(array);
|
|
11
|
+
resultArray[value] = (resultArray[value] || 0) + 1;
|
|
12
|
+
});
|
|
13
|
+
for (const item of array) {
|
|
14
|
+
expect(resultArray[item]).toBeTruthy();
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
});
|
package/lib/test/email.test.js
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
const set_1 = require("../basic/set");
|
|
4
|
+
const custom_1 = require("../custom");
|
|
5
|
+
const testUtil_1 = require("./testUtil");
|
|
6
|
+
const r = set_1.RandexSetUtil;
|
|
7
7
|
function splitEmail(email) {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const [prefix, domain] = email.split("@");
|
|
9
|
+
const [lowDomain, hightDomain] = domain.split(".");
|
|
10
10
|
return [prefix, domain, lowDomain, hightDomain];
|
|
11
11
|
}
|
|
12
12
|
function testEmail(options) {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const { email, prefixLength = r.defaultEmailPrefixLength, hightDomainLength = r.defaultHightDomainEmailLength, lowDomainLength = r.defaultLowDomainEmailLength, domain: emailDomain, } = options;
|
|
14
|
+
const [prefix, domain, lowDomain, hightDomain] = splitEmail(email);
|
|
15
15
|
// // last char only english
|
|
16
|
-
|
|
16
|
+
testUtil_1.TestUtil.testInSet(prefix, [["english", "l"], "number"], prefixLength);
|
|
17
17
|
if (emailDomain) {
|
|
18
18
|
expect(emailDomain).toBe(domain);
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
testUtil_1.TestUtil.testInSet(lowDomain, ["english"], lowDomainLength);
|
|
22
|
+
testUtil_1.TestUtil.testInSet(hightDomain, ["english"], hightDomainLength);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
describe("randomEmail",
|
|
26
|
-
it("simple",
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
testEmail({ email
|
|
25
|
+
describe("randomEmail", () => {
|
|
26
|
+
it("simple", () => {
|
|
27
|
+
testUtil_1.TestUtil.loop(() => {
|
|
28
|
+
const email = custom_1.Randex.email();
|
|
29
|
+
testEmail({ email });
|
|
30
30
|
});
|
|
31
31
|
});
|
|
32
|
-
it("options: prefixLength",
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
testEmail({ email
|
|
32
|
+
it("options: prefixLength", () => {
|
|
33
|
+
const prefixLength = [10, 15];
|
|
34
|
+
testUtil_1.TestUtil.loop(() => {
|
|
35
|
+
let email = custom_1.Randex.email({ prefixLength });
|
|
36
|
+
testEmail({ email, prefixLength });
|
|
37
37
|
email = custom_1.Randex.email(prefixLength);
|
|
38
|
-
testEmail({ email
|
|
38
|
+
testEmail({ email, prefixLength });
|
|
39
39
|
});
|
|
40
40
|
});
|
|
41
|
-
it("options: hightDomainLength, lowDomainLength",
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
testEmail({ email
|
|
41
|
+
it("options: hightDomainLength, lowDomainLength", () => {
|
|
42
|
+
const hightDomainLength = 8;
|
|
43
|
+
const lowDomainLength = 12;
|
|
44
|
+
testUtil_1.TestUtil.loop(() => {
|
|
45
|
+
let email = custom_1.Randex.email({ hightDomainLength, lowDomainLength });
|
|
46
|
+
testEmail({ email, hightDomainLength, lowDomainLength });
|
|
47
47
|
email = custom_1.Randex.email(r.defaultEmailPrefixLength, lowDomainLength, hightDomainLength);
|
|
48
|
-
testEmail({ email
|
|
48
|
+
testEmail({ email, hightDomainLength, lowDomainLength, prefixLength: r.defaultEmailPrefixLength });
|
|
49
49
|
});
|
|
50
50
|
});
|
|
51
|
-
it("options: domain",
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
testEmail({ email
|
|
51
|
+
it("options: domain", () => {
|
|
52
|
+
const domain = "delta.com";
|
|
53
|
+
testUtil_1.TestUtil.loop(() => {
|
|
54
|
+
let email = custom_1.Randex.email({ domain });
|
|
55
|
+
testEmail({ email, domain });
|
|
56
56
|
email = custom_1.Randex.email(domain);
|
|
57
|
-
testEmail({ email
|
|
57
|
+
testEmail({ email, domain });
|
|
58
58
|
});
|
|
59
59
|
});
|
|
60
60
|
});
|
|
@@ -1,66 +1,66 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
const set_1 = require("../basic/set");
|
|
4
|
+
const custom_1 = require("../custom");
|
|
5
|
+
const testUtil_1 = require("./testUtil");
|
|
6
|
+
const r = set_1.RandexSetUtil;
|
|
7
7
|
function splitFileName(fullFileName) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const matches = fullFileName.match(/\.[a-z]+$/);
|
|
9
|
+
let extension = matches?.[0] || "";
|
|
10
|
+
const fileName = fullFileName.replace(extension, "");
|
|
11
11
|
extension = extension.replace(/^\./, "");
|
|
12
12
|
return [fileName, extension];
|
|
13
13
|
}
|
|
14
14
|
function testFileName(options) {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const { fullFileName, fileNameLength = r.defaultFileNameLength, extensionLength = r.defaultExtensionLength, extension } = options;
|
|
16
|
+
const [fileName, fileExtension] = splitFileName(fullFileName);
|
|
17
17
|
// last char only english
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
testUtil_1.TestUtil.testInSet(fileName[fileName.length - 1], ["english", "number"], 1);
|
|
19
|
+
testUtil_1.TestUtil.testInSetRange(fileName, ["english", "number"], r.fileNameExtraChars, fileNameLength);
|
|
20
20
|
if (extension) {
|
|
21
21
|
expect(extension).toBe(fileExtension);
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
24
|
-
|
|
24
|
+
testUtil_1.TestUtil.testInSet(fileExtension, "english", extensionLength);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
describe("randomFileName",
|
|
28
|
-
it("simple",
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
testFileName({ fullFileName
|
|
27
|
+
describe("randomFileName", () => {
|
|
28
|
+
it("simple", () => {
|
|
29
|
+
testUtil_1.TestUtil.loop(() => {
|
|
30
|
+
const fullFileName = custom_1.Randex.fileName();
|
|
31
|
+
testFileName({ fullFileName });
|
|
32
32
|
});
|
|
33
33
|
});
|
|
34
|
-
it("params: fileNameLength",
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
testFileName({ fullFileName
|
|
34
|
+
it("params: fileNameLength", () => {
|
|
35
|
+
const fileNameLength = [10, 15];
|
|
36
|
+
testUtil_1.TestUtil.loop(() => {
|
|
37
|
+
let fullFileName = custom_1.Randex.fileName({ fileNameLength });
|
|
38
|
+
testFileName({ fullFileName, fileNameLength });
|
|
39
39
|
fullFileName = custom_1.Randex.fileName(fileNameLength);
|
|
40
|
-
testFileName({ fullFileName
|
|
40
|
+
testFileName({ fullFileName, fileNameLength });
|
|
41
41
|
});
|
|
42
42
|
});
|
|
43
|
-
it("params: extensionLength",
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
testFileName({ fullFileName
|
|
43
|
+
it("params: extensionLength", () => {
|
|
44
|
+
const extensionLength = [10, 15];
|
|
45
|
+
testUtil_1.TestUtil.loop(() => {
|
|
46
|
+
let fullFileName = custom_1.Randex.fileName({ extensionLength });
|
|
47
|
+
testFileName({ fullFileName, extensionLength });
|
|
48
48
|
fullFileName = custom_1.Randex.fileName(r.defaultFileNameLength, extensionLength);
|
|
49
|
-
testFileName({ fullFileName
|
|
49
|
+
testFileName({ fullFileName, fileNameLength: r.defaultFileNameLength, extensionLength });
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
-
it("params2: extension",
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
testFileName({ fullFileName
|
|
52
|
+
it("params2: extension", () => {
|
|
53
|
+
const fileNameLength = [10, 15];
|
|
54
|
+
const extension = "xml";
|
|
55
|
+
testUtil_1.TestUtil.loop(() => {
|
|
56
|
+
let fullFileName = custom_1.Randex.fileName({ extension });
|
|
57
|
+
testFileName({ fullFileName, extension });
|
|
58
58
|
fullFileName = custom_1.Randex.fileName(extension);
|
|
59
|
-
testFileName({ fullFileName
|
|
59
|
+
testFileName({ fullFileName, extension });
|
|
60
60
|
fullFileName = custom_1.Randex.fileName("." + extension);
|
|
61
|
-
testFileName({ fullFileName
|
|
61
|
+
testFileName({ fullFileName, extension });
|
|
62
62
|
fullFileName = custom_1.Randex.fileName(fileNameLength, extension);
|
|
63
|
-
testFileName({ fullFileName
|
|
63
|
+
testFileName({ fullFileName, fileNameLength, extension });
|
|
64
64
|
});
|
|
65
65
|
});
|
|
66
66
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
describe("randomFullName",
|
|
6
|
-
it("simple",
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
expect(
|
|
3
|
+
const custom_1 = require("../custom");
|
|
4
|
+
const testUtil_1 = require("./testUtil");
|
|
5
|
+
describe("randomFullName", () => {
|
|
6
|
+
it("simple", () => {
|
|
7
|
+
testUtil_1.TestUtil.loop(() => {
|
|
8
|
+
const value = custom_1.Randex.fullName();
|
|
9
|
+
expect(testUtil_1.TestUtil.isFullNameValid(value)).toBeTruthy();
|
|
10
10
|
});
|
|
11
11
|
});
|
|
12
12
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
describe("markdown",
|
|
5
|
-
it("random",
|
|
6
|
-
|
|
3
|
+
const custom_1 = require("../custom");
|
|
4
|
+
describe("markdown", () => {
|
|
5
|
+
it("random", () => {
|
|
6
|
+
let value = custom_1.Randex.random({
|
|
7
7
|
set: "english",
|
|
8
8
|
length: 3,
|
|
9
9
|
});
|
|
@@ -60,8 +60,8 @@ describe("markdown", function () {
|
|
|
60
60
|
value = custom_1.Randex.random(["english", 2], [["english", "number"], 2]);
|
|
61
61
|
expect(value.length).toBe(4);
|
|
62
62
|
});
|
|
63
|
-
it("randomFileName",
|
|
64
|
-
|
|
63
|
+
it("randomFileName", () => {
|
|
64
|
+
let value = custom_1.Randex.fileName();
|
|
65
65
|
value = custom_1.Randex.fileName({
|
|
66
66
|
extension: "txt",
|
|
67
67
|
});
|
|
@@ -78,12 +78,12 @@ describe("markdown", function () {
|
|
|
78
78
|
value = custom_1.Randex.fileName(8, "xml");
|
|
79
79
|
expect(value).toBeTruthy();
|
|
80
80
|
});
|
|
81
|
-
it("randomUsername",
|
|
82
|
-
|
|
81
|
+
it("randomUsername", () => {
|
|
82
|
+
const value = custom_1.Randex.username();
|
|
83
83
|
expect(value).toBeTruthy();
|
|
84
84
|
});
|
|
85
|
-
it("randomEmail",
|
|
86
|
-
|
|
85
|
+
it("randomEmail", () => {
|
|
86
|
+
let value = custom_1.Randex.email();
|
|
87
87
|
value = custom_1.Randex.email({
|
|
88
88
|
prefixLength: 8,
|
|
89
89
|
});
|
|
@@ -100,8 +100,8 @@ describe("markdown", function () {
|
|
|
100
100
|
value = custom_1.Randex.email("test.com");
|
|
101
101
|
expect(value).toBeTruthy();
|
|
102
102
|
});
|
|
103
|
-
it("singleName",
|
|
104
|
-
|
|
103
|
+
it("singleName", () => {
|
|
104
|
+
let value = custom_1.Randex.singleName();
|
|
105
105
|
expect(value).toBeTruthy();
|
|
106
106
|
value = custom_1.Randex.singleName({ alphabet: "french" });
|
|
107
107
|
expect(value).toBeTruthy();
|
|
@@ -110,8 +110,8 @@ describe("markdown", function () {
|
|
|
110
110
|
value = custom_1.Randex.singleName({ length: [2, 5] });
|
|
111
111
|
expect(value).toBeTruthy();
|
|
112
112
|
});
|
|
113
|
-
it("randomFullName",
|
|
114
|
-
|
|
113
|
+
it("randomFullName", () => {
|
|
114
|
+
const value = custom_1.Randex.fullName();
|
|
115
115
|
expect(value).toBeTruthy();
|
|
116
116
|
});
|
|
117
117
|
});
|