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.
Files changed (50) hide show
  1. package/.vscode/settings.json +1 -1
  2. package/README.md +20 -0
  3. package/eslint.config.js +29 -0
  4. package/lib/basic/set.js +48 -51
  5. package/lib/basic/type.js +27 -34
  6. package/lib/custom/bool.js +1 -2
  7. package/lib/custom/email.js +8 -9
  8. package/lib/custom/filenameX.js +7 -8
  9. package/lib/custom/fullnameX.js +7 -8
  10. package/lib/custom/index.d.ts +10 -8
  11. package/lib/custom/index.js +64 -45
  12. package/lib/custom/number.js +11 -12
  13. package/lib/custom/phrase.js +11 -12
  14. package/lib/custom/random.js +23 -29
  15. package/lib/custom/sentence.js +13 -14
  16. package/lib/custom/singleName.js +7 -8
  17. package/lib/custom/username.js +6 -7
  18. package/lib/custom/word.js +9 -10
  19. package/lib/index.js +1 -2
  20. package/lib/test/array.test.js +10 -13
  21. package/lib/test/arrayItem.test.js +17 -0
  22. package/lib/test/email.test.js +35 -35
  23. package/lib/test/filename.test.js +38 -38
  24. package/lib/test/fullname.test.js +7 -7
  25. package/lib/test/markdown.test.js +14 -14
  26. package/lib/test/name.test.js +13 -13
  27. package/lib/test/number.many.test.js +21 -24
  28. package/lib/test/number.test.js +26 -27
  29. package/lib/test/params.test.js +51 -51
  30. package/lib/test/phrase.test.js +22 -22
  31. package/lib/test/random.test.js +36 -38
  32. package/lib/test/sentence.test.js +22 -22
  33. package/lib/test/{set-util.test.js → setUtil.test.js} +7 -7
  34. package/lib/test/shuffle.test.d.ts +1 -0
  35. package/lib/test/shuffle.test.js +14 -0
  36. package/lib/test/spreader.test.js +13 -12
  37. package/lib/test/testUtil.js +121 -0
  38. package/lib/test/type.test.js +11 -14
  39. package/lib/test/username.test.js +11 -11
  40. package/lib/test/word.test.js +16 -16
  41. package/lib/utils/spreader.d.ts +1 -0
  42. package/lib/utils/spreader.js +19 -25
  43. package/package.json +4 -4
  44. package/.eslintignore +0 -3
  45. package/.eslintrc.js +0 -3
  46. package/lib/test/array-item.test.js +0 -18
  47. package/lib/test/test-util.js +0 -134
  48. /package/lib/test/{array-item.test.d.ts → arrayItem.test.d.ts} +0 -0
  49. /package/lib/test/{set-util.test.d.ts → setUtil.test.d.ts} +0 -0
  50. /package/lib/test/{test-util.d.ts → testUtil.d.ts} +0 -0
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var custom_1 = require("../custom");
4
- var test_util_1 = require("./test-util");
5
- describe("randomName", function () {
6
- it("simple", function () {
7
- test_util_1.TestUtil.loop(function () {
8
- var value = custom_1.Randex.singleName();
9
- expect(test_util_1.TestUtil.isNameValid(value)).toBeTruthy();
3
+ const custom_1 = require("../custom");
4
+ const testUtil_1 = require("./testUtil");
5
+ describe("randomName", () => {
6
+ it("simple", () => {
7
+ testUtil_1.TestUtil.loop(() => {
8
+ const value = custom_1.Randex.singleName();
9
+ expect(testUtil_1.TestUtil.isNameValid(value)).toBeTruthy();
10
10
  });
11
11
  });
12
- it("options: length", function () {
13
- var value = custom_1.Randex.singleName({ length: 5 });
12
+ it("options: length", () => {
13
+ let value = custom_1.Randex.singleName({ length: 5 });
14
14
  expect(value.length).toBe(5);
15
15
  value = custom_1.Randex.singleName(5);
16
16
  expect(value.length).toBe(5);
@@ -21,12 +21,12 @@ describe("randomName", function () {
21
21
  expect(value.length).toBe(5);
22
22
  //
23
23
  value = custom_1.Randex.singleName({ length: [1, 5] });
24
- expect(test_util_1.TestUtil.inNumberRange(value.length, [1, 5])).toBeTruthy();
24
+ expect(testUtil_1.TestUtil.inNumberRange(value.length, [1, 5])).toBeTruthy();
25
25
  value = custom_1.Randex.singleName([1, 5]);
26
- expect(test_util_1.TestUtil.inNumberRange(value.length, [1, 5])).toBeTruthy();
26
+ expect(testUtil_1.TestUtil.inNumberRange(value.length, [1, 5])).toBeTruthy();
27
27
  });
28
- it("options: alphabet", function () {
29
- var value = custom_1.Randex.singleName({ alphabet: "russian", length: 5 });
28
+ it("options: alphabet", () => {
29
+ let value = custom_1.Randex.singleName({ alphabet: "russian", length: 5 });
30
30
  expect(value.length).toBe(5);
31
31
  value = custom_1.Randex.singleName("french", 10);
32
32
  expect(value.length).toBe(10);
@@ -1,49 +1,46 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var custom_1 = require("../custom");
3
+ const custom_1 = require("../custom");
4
4
  function testNumber(min, max, count) {
5
- var value = custom_1.Randex.many(count).number([min, max]);
6
- var uniqueResult = [];
7
- for (var i = 0; i < count; i++) {
8
- var uniqueValue = value[i];
5
+ const value = custom_1.Randex.many(count).number([min, max]);
6
+ const uniqueResult = [];
7
+ for (let i = 0; i < count; i++) {
8
+ const uniqueValue = value[i];
9
9
  expect(value[i]).toBeGreaterThanOrEqual(min);
10
10
  expect(value[i]).toBeLessThanOrEqual(max);
11
11
  uniqueResult.push(uniqueValue);
12
12
  }
13
13
  }
14
- describe("random many number", function () {
15
- it("param: number", function () {
14
+ describe("random many number", () => {
15
+ it("param: number", () => {
16
16
  testNumber(0, 2, 0);
17
17
  testNumber(1, 5, 1);
18
18
  testNumber(5, 10, 2);
19
19
  });
20
- it("param: big number", function () {
20
+ it("param: big number", () => {
21
21
  testNumber(50, 500, 50);
22
22
  });
23
- it("max count - unique", function () {
23
+ it("max count - unique", () => {
24
24
  testNumber(10, 20, 11);
25
25
  });
26
- it("count limit", function () {
27
- var min = 5;
28
- var max = 10;
29
- var count = max - min + 1;
30
- var value = custom_1.Randex.many(count).number([min, max]);
26
+ it("count limit", () => {
27
+ const min = 5;
28
+ const max = 10;
29
+ const count = max - min + 1;
30
+ let value = custom_1.Randex.many(count).number([min, max]);
31
31
  expect(value.length).toBe(count);
32
32
  // max length limit
33
33
  value = custom_1.Randex.many(count + 10).number([min, max]);
34
34
  expect(value.length).toBe(count + 10);
35
35
  });
36
- it.skip("range: fill all possible values", function () {
37
- var min = 5;
38
- var max = 10;
39
- var count = max - min + 1;
40
- var value = custom_1.Randex.many(count + 10).number([min, max]);
36
+ it.skip("range: fill all possible values", () => {
37
+ const min = 5;
38
+ const max = 10;
39
+ const count = max - min + 1;
40
+ const value = custom_1.Randex.many(count + 10).number([min, max]);
41
41
  expect(value.length).toBe(count + 10);
42
- var _loop_1 = function (i) {
43
- expect(value.find(function (x) { return x === i; })).toBeTruthy();
44
- };
45
- for (var i = min; i <= max; i++) {
46
- _loop_1(i);
42
+ for (let i = min; i <= max; i++) {
43
+ expect(value.find(x => x === i)).toBeTruthy();
47
44
  }
48
45
  });
49
46
  });
@@ -1,60 +1,59 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var custom_1 = require("../custom");
4
- var test_util_1 = require("./test-util");
3
+ const custom_1 = require("../custom");
4
+ const testUtil_1 = require("./testUtil");
5
5
  function testNumber(max) {
6
- var value = custom_1.Randex.number(max);
6
+ const value = custom_1.Randex.number(max);
7
7
  expect(value).toBeGreaterThanOrEqual(0);
8
8
  expect(value).toBeLessThanOrEqual(max);
9
9
  }
10
- function testNumberWithArray(range, two) {
11
- if (two === void 0) { two = false; }
12
- var min = range[0], max = range[1];
13
- var value = two ? custom_1.Randex.number(range) : custom_1.Randex.number(min, max);
10
+ function testNumberWithArray(range, two = false) {
11
+ const [min, max] = range;
12
+ const value = two ? custom_1.Randex.number(range) : custom_1.Randex.number(min, max);
14
13
  expect(value).toBeGreaterThanOrEqual(min);
15
14
  expect(value).toBeLessThanOrEqual(max);
16
15
  }
17
- describe("randomNumber", function () {
18
- it("param: number", function () {
16
+ describe("randomNumber", () => {
17
+ it("param: number", () => {
19
18
  testNumber(0);
20
19
  testNumber(1);
21
20
  testNumber(5);
22
21
  });
23
- it("much range", function () {
24
- var max = 4;
25
- var result = {};
26
- test_util_1.TestUtil.loop(function () {
27
- var value = custom_1.Randex.number(max);
22
+ it("much range", () => {
23
+ const max = 4;
24
+ const result = {};
25
+ testUtil_1.TestUtil.loop(() => {
26
+ const value = custom_1.Randex.number(max);
28
27
  result[value] = (result[value] || 0) + 1;
29
28
  });
30
- for (var i = 0; i <= max; i++) {
29
+ for (let i = 0; i <= max; i++) {
31
30
  expect(result[i]).toBeGreaterThan(0);
32
31
  }
33
32
  });
34
- it("param: number array", function () {
35
- test_util_1.TestUtil.loop(function () {
33
+ it("param: number array", () => {
34
+ testUtil_1.TestUtil.loop(() => {
36
35
  testNumberWithArray([10, 15]);
37
36
  });
38
37
  });
39
- it("param: two numbers", function () {
40
- test_util_1.TestUtil.loop(function () {
38
+ it("param: two numbers", () => {
39
+ testUtil_1.TestUtil.loop(() => {
41
40
  testNumberWithArray([10, 15], true);
42
41
  });
43
42
  });
44
- it("two numbers with decimals", function () {
45
- var count = 0;
46
- test_util_1.TestUtil.loop(function () {
47
- var value = custom_1.Randex.number(1, 10, { decimals: 2 });
43
+ it("two numbers with decimals", () => {
44
+ let count = 0;
45
+ testUtil_1.TestUtil.loop(() => {
46
+ const value = custom_1.Randex.number(1, 10, { decimals: 2 });
48
47
  if (/\.\d{2}$/g.test(value.toString())) {
49
48
  count++;
50
49
  }
51
50
  });
52
51
  expect(count).toBeGreaterThan(1);
53
52
  });
54
- it("a number with decimals", function () {
55
- var count = 0;
56
- test_util_1.TestUtil.loop(function () {
57
- var value = custom_1.Randex.number(10, { decimals: 2 });
53
+ it("a number with decimals", () => {
54
+ let count = 0;
55
+ testUtil_1.TestUtil.loop(() => {
56
+ const value = custom_1.Randex.number(10, { decimals: 2 });
58
57
  if (/\.\d{2}$/g.test(value.toString())) {
59
58
  count++;
60
59
  }
@@ -1,61 +1,61 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var test_util_1 = require("./test-util");
4
- var custom_1 = require("../custom");
5
- describe("random params", function () {
6
- it("array 1", function () {
7
- var set = "english";
8
- var result1 = custom_1.Randex.random({ set: set });
9
- var result2 = custom_1.Randex.random(set);
10
- test_util_1.TestUtil.testInSet(result1, set);
11
- test_util_1.TestUtil.testInSet(result2, set);
3
+ const testUtil_1 = require("./testUtil");
4
+ const custom_1 = require("../custom");
5
+ describe("random params", () => {
6
+ it("array 1", () => {
7
+ const set = "english";
8
+ const result1 = custom_1.Randex.random({ set });
9
+ const result2 = custom_1.Randex.random(set);
10
+ testUtil_1.TestUtil.testInSet(result1, set);
11
+ testUtil_1.TestUtil.testInSet(result2, set);
12
12
  });
13
- it("single: array", function () {
14
- var set = ["number", "english"];
15
- var result1 = custom_1.Randex.random({ set: set });
16
- var result2 = custom_1.Randex.random(set);
17
- test_util_1.TestUtil.testInSet(result1, set);
18
- test_util_1.TestUtil.testInSet(result2, set);
13
+ it("single: array", () => {
14
+ const set = ["number", "english"];
15
+ const result1 = custom_1.Randex.random({ set });
16
+ const result2 = custom_1.Randex.random(set);
17
+ testUtil_1.TestUtil.testInSet(result1, set);
18
+ testUtil_1.TestUtil.testInSet(result2, set);
19
19
  });
20
- it("single: array, length", function () {
21
- var set = ["number", "english"];
22
- var length = 3;
23
- var result1 = custom_1.Randex.random({ set: set, length: length });
24
- var result2 = custom_1.Randex.random([set, length]);
25
- test_util_1.TestUtil.testInSet(result1, set, length);
26
- test_util_1.TestUtil.testInSet(result2, set, length);
20
+ it("single: array, length", () => {
21
+ const set = ["number", "english"];
22
+ const length = 3;
23
+ const result1 = custom_1.Randex.random({ set, length });
24
+ const result2 = custom_1.Randex.random([set, length]);
25
+ testUtil_1.TestUtil.testInSet(result1, set, length);
26
+ testUtil_1.TestUtil.testInSet(result2, set, length);
27
27
  });
28
- it("single: array, length as array", function () {
29
- var set = ["number", "english"];
30
- var length = [1, 4];
31
- var result1 = custom_1.Randex.random({ set: set, length: length });
32
- var result2 = custom_1.Randex.random([set, length]);
33
- test_util_1.TestUtil.testInSet(result1, set, length);
34
- test_util_1.TestUtil.testInSet(result2, set, length);
28
+ it("single: array, length as array", () => {
29
+ const set = ["number", "english"];
30
+ const length = [1, 4];
31
+ const result1 = custom_1.Randex.random({ set, length });
32
+ const result2 = custom_1.Randex.random([set, length]);
33
+ testUtil_1.TestUtil.testInSet(result1, set, length);
34
+ testUtil_1.TestUtil.testInSet(result2, set, length);
35
35
  });
36
- it("array 2 (range)", function () {
37
- var set = "number";
38
- var range = "abcdefghijklmnopqrstuvwxyz";
39
- var result1 = custom_1.Randex.random({ set: set, charRange: range });
40
- var result2 = custom_1.Randex.random([set, range]);
41
- test_util_1.TestUtil.testInBoth(result1, set, range);
42
- test_util_1.TestUtil.testInBoth(result2, set, range);
36
+ it("array 2 (range)", () => {
37
+ const set = "number";
38
+ const range = "abcdefghijklmnopqrstuvwxyz";
39
+ const result1 = custom_1.Randex.random({ set, charRange: range });
40
+ const result2 = custom_1.Randex.random([set, range]);
41
+ testUtil_1.TestUtil.testInBoth(result1, set, range);
42
+ testUtil_1.TestUtil.testInBoth(result2, set, range);
43
43
  });
44
- it("array 2 (length)", function () {
45
- var set = "english";
46
- var length = 3;
47
- var result1 = custom_1.Randex.random({ set: set, length: length });
48
- var result2 = custom_1.Randex.random([set, length]);
49
- test_util_1.TestUtil.testInSet(result1, set, length);
50
- test_util_1.TestUtil.testInSet(result2, set, length);
44
+ it("array 2 (length)", () => {
45
+ const set = "english";
46
+ const length = 3;
47
+ const result1 = custom_1.Randex.random({ set, length });
48
+ const result2 = custom_1.Randex.random([set, length]);
49
+ testUtil_1.TestUtil.testInSet(result1, set, length);
50
+ testUtil_1.TestUtil.testInSet(result2, set, length);
51
51
  });
52
- it("array 3", function () {
53
- var set = "number";
54
- var range = "abcdefghijklmnopqrstuvwxyz";
55
- var length = 3;
56
- var result1 = custom_1.Randex.random({ set: set, charRange: range, length: length });
57
- var result2 = custom_1.Randex.random([set, range, length]);
58
- test_util_1.TestUtil.testInBoth(result1, set, range, length);
59
- test_util_1.TestUtil.testInBoth(result2, set, range, length);
52
+ it("array 3", () => {
53
+ const set = "number";
54
+ const range = "abcdefghijklmnopqrstuvwxyz";
55
+ const length = 3;
56
+ const result1 = custom_1.Randex.random({ set, charRange: range, length });
57
+ const result2 = custom_1.Randex.random([set, range, length]);
58
+ testUtil_1.TestUtil.testInBoth(result1, set, range, length);
59
+ testUtil_1.TestUtil.testInBoth(result2, set, range, length);
60
60
  });
61
61
  });
@@ -1,33 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var custom_1 = require("../custom");
4
- var test_util_1 = require("./test-util");
5
- describe("phrase", function () {
6
- it("default", function () {
7
- test_util_1.TestUtil.loop(function () {
8
- var text = custom_1.Randex.phrase();
9
- expect(test_util_1.TestUtil.isPhraseValid(text)).toBeTruthy();
3
+ const custom_1 = require("../custom");
4
+ const testUtil_1 = require("./testUtil");
5
+ describe("phrase", () => {
6
+ it("default", () => {
7
+ testUtil_1.TestUtil.loop(() => {
8
+ const text = custom_1.Randex.phrase();
9
+ expect(testUtil_1.TestUtil.isPhraseValid(text)).toBeTruthy();
10
10
  });
11
11
  });
12
- it("range", function () {
13
- var range = [10, 20];
14
- test_util_1.TestUtil.loop(function () {
15
- var text = custom_1.Randex.phrase(range);
16
- expect(test_util_1.TestUtil.isPhraseValid(text, range)).toBeTruthy();
12
+ it("range", () => {
13
+ const range = [10, 20];
14
+ testUtil_1.TestUtil.loop(() => {
15
+ const text = custom_1.Randex.phrase(range);
16
+ expect(testUtil_1.TestUtil.isPhraseValid(text, range)).toBeTruthy();
17
17
  });
18
18
  });
19
- it("specific number", function () {
20
- var range = 5;
21
- test_util_1.TestUtil.loop(function () {
22
- var text = custom_1.Randex.phrase(range);
23
- expect(test_util_1.TestUtil.isPhraseValid(text, range)).toBeTruthy();
19
+ it("specific number", () => {
20
+ const range = 5;
21
+ testUtil_1.TestUtil.loop(() => {
22
+ const text = custom_1.Randex.phrase(range);
23
+ expect(testUtil_1.TestUtil.isPhraseValid(text, range)).toBeTruthy();
24
24
  });
25
25
  });
26
- it("many", function () {
27
- var count = 5;
28
- var phrases = custom_1.Randex.many(count).phrase();
29
- for (var i = 0; i < count; i++) {
30
- expect(test_util_1.TestUtil.isPhraseValid(phrases[i])).toBeTruthy();
26
+ it("many", () => {
27
+ const count = 5;
28
+ const phrases = custom_1.Randex.many(count).phrase();
29
+ for (let i = 0; i < count; i++) {
30
+ expect(testUtil_1.TestUtil.isPhraseValid(phrases[i])).toBeTruthy();
31
31
  }
32
32
  });
33
33
  });
@@ -1,19 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var test_util_1 = require("./test-util");
4
- var custom_1 = require("../custom");
5
- function inSet(set, length) {
6
- if (length === void 0) { length = 1; }
7
- var result = custom_1.Randex.random({ set: set, length: length });
8
- test_util_1.TestUtil.testInSet(result, set, length);
3
+ const testUtil_1 = require("./testUtil");
4
+ const custom_1 = require("../custom");
5
+ function inSet(set, length = 1) {
6
+ const result = custom_1.Randex.random({ set, length });
7
+ testUtil_1.TestUtil.testInSet(result, set, length);
9
8
  }
10
- function inRange(range, length) {
11
- if (length === void 0) { length = 1; }
12
- var result = custom_1.Randex.random({ charRange: range, length: length });
13
- test_util_1.TestUtil.testInRange(result, range, length);
9
+ function inRange(range, length = 1) {
10
+ const result = custom_1.Randex.random({ charRange: range, length });
11
+ testUtil_1.TestUtil.testInRange(result, range, length);
14
12
  }
15
- describe("random", function () {
16
- it("set", function () {
13
+ describe("random", () => {
14
+ it("set", () => {
17
15
  inSet("english", 3);
18
16
  inSet(["english", "l"], 3);
19
17
  inSet(["english", "u"], 3);
@@ -22,64 +20,64 @@ describe("random", function () {
22
20
  inSet("number", 3);
23
21
  inSet("binary", 3);
24
22
  });
25
- it("range", function () {
23
+ it("range", () => {
26
24
  inRange("abc", 3);
27
25
  inRange("1234abc!@#", 3);
28
26
  });
29
- it("result 1: number", function () {
30
- var length = [0, 4];
31
- var result = {};
32
- test_util_1.TestUtil.loop(function () {
33
- var l = custom_1.Randex.random({ set: "english", length: length }).length;
27
+ it("result 1: number", () => {
28
+ const length = [0, 4];
29
+ const result = {};
30
+ testUtil_1.TestUtil.loop(() => {
31
+ const l = custom_1.Randex.random({ set: "english", length }).length;
34
32
  result[l] = (result[l] || 0) + 1;
35
33
  });
36
- for (var i = 0; i <= 4; i++) {
34
+ for (let i = 0; i <= 4; i++) {
37
35
  expect(result[i]).toBeGreaterThan(0);
38
36
  }
39
37
  });
40
- it("result 2: number range", function () {
41
- var length = [5, 8];
42
- var result = {};
43
- test_util_1.TestUtil.loop(function () {
44
- var l = custom_1.Randex.random({ set: "english", length: length }).length;
38
+ it("result 2: number range", () => {
39
+ const length = [5, 8];
40
+ const result = {};
41
+ testUtil_1.TestUtil.loop(() => {
42
+ const l = custom_1.Randex.random({ set: "english", length }).length;
45
43
  result[l] = (result[l] || 0) + 1;
46
44
  });
47
- for (var i = 5; i <= 8; i++) {
45
+ for (let i = 5; i <= 8; i++) {
48
46
  expect(result[i]).toBeGreaterThan(0);
49
47
  }
50
48
  });
51
- it("length: alphabet", function () {
49
+ it("length: alphabet", () => {
52
50
  inSet("english", 0);
53
51
  inSet("english", [0, 0]);
54
52
  inSet("english", [1, 3]);
55
53
  inSet("english", [0, 1]);
56
54
  });
57
- it("length: alphabet", function () {
58
- var value = custom_1.Randex.random("english");
55
+ it("length: alphabet", () => {
56
+ let value = custom_1.Randex.random("english");
59
57
  expect(value.length).toBe(1);
60
58
  value = custom_1.Randex.random(["english", "l"]);
61
59
  expect(value.length).toBe(1);
62
60
  });
63
- it("alphabet: upper", function () {
64
- test_util_1.TestUtil.loop(function () {
65
- var value = custom_1.Randex.random(["english", "u"]);
66
- expect(test_util_1.TestUtil.isUpperCharValid(value, 1)).toBeTruthy();
61
+ it("alphabet: upper", () => {
62
+ testUtil_1.TestUtil.loop(() => {
63
+ let value = custom_1.Randex.random(["english", "u"]);
64
+ expect(testUtil_1.TestUtil.isUpperCharValid(value, 1)).toBeTruthy();
67
65
  value = custom_1.Randex.random([
68
66
  ["english", "u"],
69
67
  [1, 3],
70
68
  ]);
71
- expect(test_util_1.TestUtil.isUpperCharValid(value, [1, 3])).toBeTruthy();
69
+ expect(testUtil_1.TestUtil.isUpperCharValid(value, [1, 3])).toBeTruthy();
72
70
  });
73
71
  });
74
- it("alphabet: lower", function () {
75
- test_util_1.TestUtil.loop(function () {
76
- var value = custom_1.Randex.random(["english", "l"]);
77
- expect(test_util_1.TestUtil.isLowerCharValid(value, 1)).toBeTruthy();
72
+ it("alphabet: lower", () => {
73
+ testUtil_1.TestUtil.loop(() => {
74
+ let value = custom_1.Randex.random(["english", "l"]);
75
+ expect(testUtil_1.TestUtil.isLowerCharValid(value, 1)).toBeTruthy();
78
76
  value = custom_1.Randex.random([
79
77
  ["english", "lower"],
80
78
  [1, 3],
81
79
  ]);
82
- expect(test_util_1.TestUtil.isLowerCharValid(value, [1, 3])).toBeTruthy();
80
+ expect(testUtil_1.TestUtil.isLowerCharValid(value, [1, 3])).toBeTruthy();
83
81
  });
84
82
  });
85
83
  });
@@ -1,33 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var custom_1 = require("../custom");
4
- var test_util_1 = require("./test-util");
5
- describe("sentence", function () {
6
- it("default", function () {
7
- test_util_1.TestUtil.loop(function () {
8
- var text = custom_1.Randex.sentence();
9
- expect(test_util_1.TestUtil.isSentenceValid(text)).toBeTruthy();
3
+ const custom_1 = require("../custom");
4
+ const testUtil_1 = require("./testUtil");
5
+ describe("sentence", () => {
6
+ it("default", () => {
7
+ testUtil_1.TestUtil.loop(() => {
8
+ const text = custom_1.Randex.sentence();
9
+ expect(testUtil_1.TestUtil.isSentenceValid(text)).toBeTruthy();
10
10
  });
11
11
  });
12
- it("range", function () {
13
- var range = [10, 20];
14
- test_util_1.TestUtil.loop(function () {
15
- var text = custom_1.Randex.sentence(range);
16
- expect(test_util_1.TestUtil.isSentenceValid(text, range)).toBeTruthy();
12
+ it("range", () => {
13
+ const range = [10, 20];
14
+ testUtil_1.TestUtil.loop(() => {
15
+ const text = custom_1.Randex.sentence(range);
16
+ expect(testUtil_1.TestUtil.isSentenceValid(text, range)).toBeTruthy();
17
17
  });
18
18
  });
19
- it("specific number", function () {
20
- var range = 5;
21
- test_util_1.TestUtil.loop(function () {
22
- var text = custom_1.Randex.sentence(range);
23
- expect(test_util_1.TestUtil.isSentenceValid(text, range)).toBeTruthy();
19
+ it("specific number", () => {
20
+ const range = 5;
21
+ testUtil_1.TestUtil.loop(() => {
22
+ const text = custom_1.Randex.sentence(range);
23
+ expect(testUtil_1.TestUtil.isSentenceValid(text, range)).toBeTruthy();
24
24
  });
25
25
  });
26
- it("many", function () {
27
- var count = 5;
28
- var sentences = custom_1.Randex.many(count).sentence();
29
- for (var i = 0; i < count; i++) {
30
- expect(test_util_1.TestUtil.isSentenceValid(sentences[i])).toBeTruthy();
26
+ it("many", () => {
27
+ const count = 5;
28
+ const sentences = custom_1.Randex.many(count).sentence();
29
+ for (let i = 0; i < count; i++) {
30
+ expect(testUtil_1.TestUtil.isSentenceValid(sentences[i])).toBeTruthy();
31
31
  }
32
32
  });
33
33
  });
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var set_1 = require("../basic/set");
4
- var defaultLength = [1, 10];
3
+ const set_1 = require("../basic/set");
4
+ const defaultLength = [1, 10];
5
5
  function getLength(reservedChars, length, resultLength) {
6
- var result = set_1.RandexSetUtil.getLength(reservedChars, length, defaultLength);
6
+ const result = set_1.RandexSetUtil.getLength(reservedChars, length, defaultLength);
7
7
  if (typeof resultLength === "number") {
8
8
  expect(result).toBe(resultLength);
9
9
  }
@@ -11,15 +11,15 @@ function getLength(reservedChars, length, resultLength) {
11
11
  expect(result).toMatchObject(resultLength);
12
12
  }
13
13
  }
14
- describe("RandexSetUtil", function () {
15
- describe("getLength", function () {
16
- it("single", function () {
14
+ describe("RandexSetUtil", () => {
15
+ describe("getLength", () => {
16
+ it("single", () => {
17
17
  getLength(0, 2, 2);
18
18
  getLength(1, 3, 2);
19
19
  getLength(0, undefined, defaultLength);
20
20
  getLength(5, 3, defaultLength);
21
21
  });
22
- it("array", function () {
22
+ it("array", () => {
23
23
  getLength(0, [1, 2], [1, 2]);
24
24
  getLength(1, [2, 3], [1, 2]);
25
25
  getLength(3, [1, 5], defaultLength);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const custom_1 = require("../custom");
4
+ describe("shuffle", () => {
5
+ it("shuffles the array in place and returns it", () => {
6
+ const array = [1, 2, 3];
7
+ const randomSpy = jest.spyOn(Math, "random");
8
+ randomSpy.mockReturnValueOnce(0).mockReturnValueOnce(0.5).mockReturnValueOnce(0.99);
9
+ const result = custom_1.Randex.shuffle(array);
10
+ expect(result).toBe(array);
11
+ expect(array).toEqual([3, 2, 1]);
12
+ randomSpy.mockRestore();
13
+ });
14
+ });