stringzy 3.0.0 → 4.1.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/.prettierignore +4 -0
- package/.prettierrc +7 -0
- package/CONTRIBUTING.md +41 -29
- package/README.md +811 -163
- package/dist/analyzing/characterCount.d.ts +19 -0
- package/dist/analyzing/characterCount.js +21 -2
- package/dist/analyzing/characterFrequency.d.ts +19 -0
- package/dist/analyzing/characterFrequency.js +22 -3
- package/dist/analyzing/checkMultiplePatterns.d.ts +14 -0
- package/dist/analyzing/checkMultiplePatterns.js +63 -0
- package/dist/analyzing/checkSubsequence.d.ts +14 -0
- package/dist/analyzing/checkSubsequence.js +33 -0
- package/dist/analyzing/complexity.d.ts +33 -0
- package/dist/analyzing/complexity.js +35 -2
- package/dist/analyzing/contentWordCount.d.ts +11 -0
- package/dist/analyzing/contentWordCount.js +23 -0
- package/dist/analyzing/functionWordCount.d.ts +11 -0
- package/dist/analyzing/functionWordCount.js +33 -0
- package/dist/analyzing/index.d.ts +29 -12
- package/dist/analyzing/index.js +26 -2
- package/dist/analyzing/patternCount.d.ts +11 -0
- package/dist/analyzing/patternCount.js +54 -0
- package/dist/analyzing/stringRotation.d.ts +29 -0
- package/dist/analyzing/stringRotation.js +44 -0
- package/dist/analyzing/stringSimilarity.js +1 -1
- package/dist/analyzing/vowelConsonantCount.d.ts +22 -0
- package/dist/analyzing/vowelConsonantCount.js +38 -0
- package/dist/analyzing/wordCount.d.ts +22 -0
- package/dist/analyzing/wordCount.js +24 -2
- package/dist/formatting/capitalize.d.ts +21 -0
- package/dist/formatting/capitalize.js +22 -1
- package/dist/formatting/index.d.ts +6 -6
- package/dist/formatting/number.d.ts +23 -0
- package/dist/formatting/number.js +24 -1
- package/dist/formatting/phone.d.ts +23 -0
- package/dist/formatting/phone.js +23 -0
- package/dist/index.d.ts +22 -4
- package/dist/tests/analyzing/checkMultiplePatterns.test.d.ts +1 -0
- package/dist/tests/analyzing/checkMultiplePatterns.test.js +81 -0
- package/dist/tests/analyzing/checkSubsequence.test.d.ts +1 -0
- package/dist/tests/analyzing/checkSubsequence.test.js +34 -0
- package/dist/tests/analyzing/contentWordCount.test.d.ts +1 -0
- package/dist/tests/analyzing/contentWordCount.test.js +20 -0
- package/dist/tests/analyzing/functionWordCount.test.d.ts +1 -0
- package/dist/tests/analyzing/functionWordCount.test.js +20 -0
- package/dist/tests/analyzing/patternCount.test.d.ts +1 -0
- package/dist/tests/analyzing/patternCount.test.js +34 -0
- package/dist/tests/analyzing/readingDuration.test.js +12 -12
- package/dist/tests/analyzing/stringRotation.test.d.ts +1 -0
- package/dist/tests/analyzing/stringRotation.test.js +42 -0
- package/dist/tests/analyzing/vowelConsonantCount.test.d.ts +1 -0
- package/dist/tests/analyzing/vowelConsonantCount.test.js +25 -0
- package/dist/tests/transformations/numberToText.test.d.ts +1 -0
- package/dist/tests/transformations/numberToText.test.js +60 -0
- package/dist/tests/transformations/reverseString.test.d.ts +1 -0
- package/dist/tests/transformations/reverseString.test.js +41 -0
- package/dist/tests/transformations/splitChunks.test.d.ts +1 -0
- package/dist/tests/transformations/splitChunks.test.js +31 -0
- package/dist/tests/transformations/stringCombinations.test.d.ts +1 -0
- package/dist/tests/transformations/stringCombinations.test.js +41 -0
- package/dist/tests/transformations/stringPermutations.test.d.ts +1 -0
- package/dist/tests/transformations/stringPermutations.test.js +40 -0
- package/dist/tests/validations/isAlphaNumeric.test.d.ts +1 -0
- package/dist/tests/validations/isAlphaNumeric.test.js +30 -0
- package/dist/tests/validations/isAlphabetic.test.d.ts +1 -0
- package/dist/tests/validations/isAlphabetic.test.js +32 -0
- package/dist/tests/validations/isAnagram.test.d.ts +1 -0
- package/dist/tests/validations/isAnagram.test.js +44 -0
- package/dist/tests/validations/isCoordinates.test.d.ts +1 -0
- package/dist/tests/validations/isCoordinates.test.js +18 -0
- package/dist/tests/validations/isEmail.smtpUTF8.test.d.ts +1 -0
- package/dist/tests/validations/isEmail.smtpUTF8.test.js +16 -0
- package/dist/tests/validations/isEmail.test.js +56 -6
- package/dist/tests/validations/isHexColor.test.js +21 -21
- package/dist/tests/validations/isLowerCase.test.d.ts +1 -0
- package/dist/tests/validations/isLowerCase.test.js +50 -0
- package/dist/tests/validations/isMacAddress.test.d.ts +1 -0
- package/dist/tests/validations/isMacAddress.test.js +72 -0
- package/dist/tests/validations/isPalindrome.test.d.ts +1 -0
- package/dist/tests/validations/isPalindrome.test.js +39 -0
- package/dist/tests/validations/isPanagram.test.d.ts +1 -0
- package/dist/tests/validations/isPanagram.test.js +39 -0
- package/dist/tests/validations/isTypeOf.test.d.ts +1 -0
- package/dist/tests/validations/isTypeOf.test.js +28 -0
- package/dist/tests/validations/isUpperCase.test.d.ts +1 -0
- package/dist/tests/validations/isUpperCase.test.js +50 -0
- package/dist/transformations/camelCase.d.ts +24 -0
- package/dist/transformations/camelCase.js +24 -0
- package/dist/transformations/capitalizeWords.d.ts +21 -0
- package/dist/transformations/capitalizeWords.js +23 -2
- package/dist/transformations/constantCase.d.ts +26 -0
- package/dist/transformations/constantCase.js +26 -0
- package/dist/transformations/escapeHTML.d.ts +23 -0
- package/dist/transformations/escapeHTML.js +24 -2
- package/dist/transformations/index.d.ts +12 -0
- package/dist/transformations/index.js +18 -2
- package/dist/transformations/initials.d.ts +27 -0
- package/dist/transformations/initials.js +38 -8
- package/dist/transformations/kebabCase.d.ts +26 -0
- package/dist/transformations/kebabCase.js +26 -0
- package/dist/transformations/maskSegment.js +4 -6
- package/dist/transformations/numberToText/helpers.d.ts +10 -0
- package/dist/transformations/numberToText/helpers.js +31 -0
- package/dist/transformations/numberToText/implementation_EN.d.ts +10 -0
- package/dist/transformations/numberToText/implementation_EN.js +45 -0
- package/dist/transformations/numberToText/implementation_PL.d.ts +10 -0
- package/dist/transformations/numberToText/implementation_PL.js +79 -0
- package/dist/transformations/numberToText/main.d.ts +19 -0
- package/dist/transformations/numberToText/main.js +67 -0
- package/dist/transformations/numberToText/types.d.ts +3 -0
- package/dist/transformations/numberToText/types.js +82 -0
- package/dist/transformations/pascalCase.d.ts +25 -0
- package/dist/transformations/pascalCase.js +25 -0
- package/dist/transformations/removeDuplicates.d.ts +21 -0
- package/dist/transformations/removeDuplicates.js +25 -4
- package/dist/transformations/removeSpecialChars.d.ts +22 -0
- package/dist/transformations/removeSpecialChars.js +26 -4
- package/dist/transformations/removeWords.d.ts +27 -0
- package/dist/transformations/removeWords.js +31 -4
- package/dist/transformations/reverseWordsInString .d.ts +9 -0
- package/dist/transformations/reverseWordsInString .js +49 -0
- package/dist/transformations/snakeCase.d.ts +26 -0
- package/dist/transformations/snakeCase.js +26 -0
- package/dist/transformations/splitChunks.d.ts +8 -0
- package/dist/transformations/splitChunks.js +24 -0
- package/dist/transformations/stringCombinations.d.ts +28 -0
- package/dist/transformations/stringCombinations.js +44 -0
- package/dist/transformations/stringPermutations.d.ts +31 -0
- package/dist/transformations/stringPermutations.js +53 -0
- package/dist/transformations/titleCase.d.ts +25 -0
- package/dist/transformations/titleCase.js +25 -0
- package/dist/transformations/toSlug.d.ts +24 -0
- package/dist/transformations/toSlug.js +28 -4
- package/dist/transformations/truncateText.d.ts +25 -0
- package/dist/transformations/truncateText.js +28 -3
- package/dist/validations/index.d.ts +27 -0
- package/dist/validations/index.js +38 -2
- package/dist/validations/isAlphaNumeric.d.ts +11 -0
- package/dist/validations/isAlphaNumeric.js +22 -0
- package/dist/validations/isAlphabetic.d.ts +9 -0
- package/dist/validations/isAlphabetic.js +21 -0
- package/dist/validations/isAnagram.d.ts +13 -0
- package/dist/validations/isAnagram.js +23 -0
- package/dist/validations/isCoordinates.d.ts +8 -0
- package/dist/validations/isCoordinates.js +19 -0
- package/dist/validations/isDate.d.ts +1 -1
- package/dist/validations/isDate.js +6 -8
- package/dist/validations/isEmail.d.ts +13 -1
- package/dist/validations/isEmail.js +176 -3
- package/dist/validations/isEmpty.d.ts +9 -0
- package/dist/validations/isEmpty.js +9 -0
- package/dist/validations/isHexColor.js +1 -1
- package/dist/validations/isIPv4.d.ts +21 -0
- package/dist/validations/isIPv4.js +22 -2
- package/dist/validations/isLowerCase.d.ts +12 -0
- package/dist/validations/isLowerCase.js +32 -0
- package/dist/validations/isMacAddress.d.ts +27 -0
- package/dist/validations/isMacAddress.js +43 -0
- package/dist/validations/isPalindrome.d.ts +10 -0
- package/dist/validations/isPalindrome.js +21 -0
- package/dist/validations/isPanagram.d.ts +20 -0
- package/dist/validations/isPanagram.js +35 -0
- package/dist/validations/isSlug.d.ts +27 -0
- package/dist/validations/isSlug.js +27 -0
- package/dist/validations/isTypeOf.d.ts +9 -0
- package/dist/validations/isTypeOf.js +30 -0
- package/dist/validations/isURL.d.ts +21 -0
- package/dist/validations/isURL.js +21 -0
- package/dist/validations/isUpperCase.d.ts +12 -0
- package/dist/validations/isUpperCase.js +32 -0
- package/package.json +6 -4
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_test_1 = require("node:test");
|
|
7
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
8
|
+
const stringRotation_1 = require("../../analyzing/stringRotation");
|
|
9
|
+
(0, node_test_1.describe)('checkStringRotations', () => {
|
|
10
|
+
(0, node_test_1.it)('returns true for valid rotations', () => {
|
|
11
|
+
node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('abcd', 'cdab'), true);
|
|
12
|
+
node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('hello', 'ohell'), true);
|
|
13
|
+
node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('12345', '45123'), true);
|
|
14
|
+
node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('!@#$', '#$!@'), true);
|
|
15
|
+
});
|
|
16
|
+
(0, node_test_1.it)('returns false for invalid rotations', () => {
|
|
17
|
+
node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('abc', 'acb'), false);
|
|
18
|
+
node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('hello', 'helol'), false);
|
|
19
|
+
node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('12345', '54321'), false);
|
|
20
|
+
});
|
|
21
|
+
(0, node_test_1.it)('is case-sensitive', () => {
|
|
22
|
+
node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('ArB', 'Bar'), false);
|
|
23
|
+
node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('Case', 'case'), false);
|
|
24
|
+
node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('XYZ', 'yzx'), false);
|
|
25
|
+
});
|
|
26
|
+
(0, node_test_1.it)('returns true for empty strings', () => {
|
|
27
|
+
node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('', ''), true);
|
|
28
|
+
});
|
|
29
|
+
(0, node_test_1.it)('returns false for strings of different lengths', () => {
|
|
30
|
+
node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('abc', 'ab'), false);
|
|
31
|
+
node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('abcd', ''), false);
|
|
32
|
+
});
|
|
33
|
+
(0, node_test_1.it)('handles special characters correctly', () => {
|
|
34
|
+
node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('a@b$c', 'b$ca@'), true);
|
|
35
|
+
node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('a@b$c', 'c$a@b'), false);
|
|
36
|
+
});
|
|
37
|
+
(0, node_test_1.it)('throws an error if inputs are not strings', () => {
|
|
38
|
+
node_assert_1.default.throws(() => (0, stringRotation_1.checkStringRotations)(123, '123'), /Both inputs must be strings/);
|
|
39
|
+
node_assert_1.default.throws(() => (0, stringRotation_1.checkStringRotations)('abc', null), /Both inputs must be strings/);
|
|
40
|
+
node_assert_1.default.throws(() => (0, stringRotation_1.checkStringRotations)(undefined, 'abc'), /Both inputs must be strings/);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_test_1 = require("node:test");
|
|
7
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
8
|
+
const vowelConsonantCount_1 = require("../../analyzing/vowelConsonantCount");
|
|
9
|
+
(0, node_test_1.describe)('vowelConsonantCount', () => {
|
|
10
|
+
(0, node_test_1.it)('returns 0s for empty string', () => {
|
|
11
|
+
node_assert_1.default.deepStrictEqual((0, vowelConsonantCount_1.vowelConsonantCount)(''), { vowels: 0, consonants: 0 });
|
|
12
|
+
});
|
|
13
|
+
(0, node_test_1.it)('counts lowercase vowels and consonants', () => {
|
|
14
|
+
node_assert_1.default.deepStrictEqual((0, vowelConsonantCount_1.vowelConsonantCount)('hello'), { vowels: 2, consonants: 3 });
|
|
15
|
+
});
|
|
16
|
+
(0, node_test_1.it)('counts uppercase vowels and consonants', () => {
|
|
17
|
+
node_assert_1.default.deepStrictEqual((0, vowelConsonantCount_1.vowelConsonantCount)('HELLO'), { vowels: 2, consonants: 3 });
|
|
18
|
+
});
|
|
19
|
+
(0, node_test_1.it)('counts vowels and consonants ignoring special characters and whitespaces', () => {
|
|
20
|
+
node_assert_1.default.deepStrictEqual((0, vowelConsonantCount_1.vowelConsonantCount)('Hello, World!'), { vowels: 3, consonants: 7 });
|
|
21
|
+
});
|
|
22
|
+
(0, node_test_1.it)('throws if input is not a string', () => {
|
|
23
|
+
node_assert_1.default.throws(() => (0, vowelConsonantCount_1.vowelConsonantCount)(123), /Input must be a string/);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_test_1 = require("node:test");
|
|
7
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
8
|
+
const transformations_1 = require("../../transformations");
|
|
9
|
+
(0, node_test_1.describe)("numberToText", () => {
|
|
10
|
+
(0, node_test_1.describe)("Param error handling", () => {
|
|
11
|
+
node_assert_1.default.throws(() => (0, transformations_1.numberToText)("aaaa"), /Num param should be number/i);
|
|
12
|
+
node_assert_1.default.throws(() => (0, transformations_1.numberToText)(1000000000001), RangeError);
|
|
13
|
+
node_assert_1.default.throws(() => (0, transformations_1.numberToText)(-1000000000001), RangeError);
|
|
14
|
+
const validLanguages = ['en', 'pl'];
|
|
15
|
+
const errorMessage = `Language must be one of: ${validLanguages.join(', ')}`;
|
|
16
|
+
node_assert_1.default.throws(() => (0, transformations_1.numberToText)(123, "invalid"), new RegExp(errorMessage, "i"));
|
|
17
|
+
});
|
|
18
|
+
(0, node_test_1.describe)("Conversion cases - en", () => {
|
|
19
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(0), "zero");
|
|
20
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(1), "one");
|
|
21
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(5), "five");
|
|
22
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(10), "ten");
|
|
23
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(15), "fifteen");
|
|
24
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(21), "twenty-one");
|
|
25
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(99), "ninety-nine");
|
|
26
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(100), "one hundred");
|
|
27
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(101), "one hundred one");
|
|
28
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(215), "two hundred fifteen");
|
|
29
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(1000), "one thousand");
|
|
30
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(2023), "two thousand twenty-three");
|
|
31
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(1000000), "one million");
|
|
32
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(1200000), "one million two hundred thousand");
|
|
33
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(1000000000), "one billion");
|
|
34
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(1000000000000), "one trillion");
|
|
35
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(-1), "minus one");
|
|
36
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(-215), "minus two hundred fifteen");
|
|
37
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(-1000000), "minus one million");
|
|
38
|
+
});
|
|
39
|
+
(0, node_test_1.describe)("Conversion cases - pl", () => {
|
|
40
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(0, 'pl'), "zero");
|
|
41
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(1, 'pl'), "jeden");
|
|
42
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(5, 'pl'), "pięć");
|
|
43
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(10, 'pl'), "dziesięć");
|
|
44
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(15, 'pl'), "piętnaście");
|
|
45
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(21, 'pl'), "dwadzieścia jeden");
|
|
46
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(99, 'pl'), "dziewięćdziesiąt dziewięć");
|
|
47
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(100, 'pl'), "sto");
|
|
48
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(101, 'pl'), "sto jeden");
|
|
49
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(215, 'pl'), "dwieście piętnaście");
|
|
50
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(1000, 'pl'), "tysiąc");
|
|
51
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(2023, 'pl'), "dwa tysiące dwadzieścia trzy");
|
|
52
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(1000000, 'pl'), "milion");
|
|
53
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(1200000, 'pl'), "milion dwieście tysięcy");
|
|
54
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(1000000000, 'pl'), "miliard");
|
|
55
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(1000000000000, 'pl'), "bilion");
|
|
56
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(-1, 'pl'), "minus jeden");
|
|
57
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(-215, 'pl'), "minus dwieście piętnaście");
|
|
58
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(-1000000, 'pl'), "minus milion");
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_test_1 = require("node:test");
|
|
7
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
8
|
+
const reverseWordsInString_1 = require("../../transformations/reverseWordsInString ");
|
|
9
|
+
(0, node_test_1.describe)('reverseWordsInString', () => {
|
|
10
|
+
(0, node_test_1.it)('reverses words while preserving multiple spaces between them', () => {
|
|
11
|
+
node_assert_1.default.strictEqual((0, reverseWordsInString_1.reverseWordsInString)('Hello world from stringzy'), 'stringzy from world Hello');
|
|
12
|
+
});
|
|
13
|
+
(0, node_test_1.it)('preserves the exact leading and trailing spaces', () => {
|
|
14
|
+
node_assert_1.default.strictEqual((0, reverseWordsInString_1.reverseWordsInString)(' leading and trailing '), ' trailing and leading ');
|
|
15
|
+
node_assert_1.default.strictEqual((0, reverseWordsInString_1.reverseWordsInString)('leading and trailing '), 'trailing and leading ');
|
|
16
|
+
node_assert_1.default.strictEqual((0, reverseWordsInString_1.reverseWordsInString)(' leading and trailing'), ' trailing and leading');
|
|
17
|
+
});
|
|
18
|
+
(0, node_test_1.it)('handles a complex mix of spacing correctly', () => {
|
|
19
|
+
node_assert_1.default.strictEqual((0, reverseWordsInString_1.reverseWordsInString)(' first second third '), ' third second first ');
|
|
20
|
+
});
|
|
21
|
+
(0, node_test_1.it)('handles a single word with or without spaces', () => {
|
|
22
|
+
node_assert_1.default.strictEqual((0, reverseWordsInString_1.reverseWordsInString)('singleword'), 'singleword');
|
|
23
|
+
node_assert_1.default.strictEqual((0, reverseWordsInString_1.reverseWordsInString)(' singleword '), ' singleword ');
|
|
24
|
+
});
|
|
25
|
+
(0, node_test_1.it)('returns the original string if it contains only whitespace', () => {
|
|
26
|
+
node_assert_1.default.strictEqual((0, reverseWordsInString_1.reverseWordsInString)(' '), ' ');
|
|
27
|
+
node_assert_1.default.strictEqual((0, reverseWordsInString_1.reverseWordsInString)('\t \n'), '\t \n');
|
|
28
|
+
});
|
|
29
|
+
(0, node_test_1.it)('returns an empty string for an empty input', () => {
|
|
30
|
+
node_assert_1.default.strictEqual((0, reverseWordsInString_1.reverseWordsInString)(''), '');
|
|
31
|
+
});
|
|
32
|
+
(0, node_test_1.it)('handles words with numbers and special characters correctly', () => {
|
|
33
|
+
node_assert_1.default.strictEqual((0, reverseWordsInString_1.reverseWordsInString)('word1! word2@#$'), 'word2@#$ word1!');
|
|
34
|
+
});
|
|
35
|
+
(0, node_test_1.it)('throws a TypeError if the input is not a string', () => {
|
|
36
|
+
node_assert_1.default.throws(() => (0, reverseWordsInString_1.reverseWordsInString)(12345), /Input must be a string/);
|
|
37
|
+
node_assert_1.default.throws(() => (0, reverseWordsInString_1.reverseWordsInString)(null), /Input must be a string/);
|
|
38
|
+
node_assert_1.default.throws(() => (0, reverseWordsInString_1.reverseWordsInString)(undefined), /Input must be a string/);
|
|
39
|
+
node_assert_1.default.throws(() => (0, reverseWordsInString_1.reverseWordsInString)({}), /Input must be a string/);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_test_1 = require("node:test");
|
|
7
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
8
|
+
const splitChunks_1 = require("../../transformations/splitChunks");
|
|
9
|
+
(0, node_test_1.describe)('splitChunks', () => {
|
|
10
|
+
(0, node_test_1.it)('creates chunks of size 3', () => {
|
|
11
|
+
node_assert_1.default.deepStrictEqual((0, splitChunks_1.splitChunks)('hello world', 3), ['hel', 'lo ', 'wor', 'ld']);
|
|
12
|
+
});
|
|
13
|
+
(0, node_test_1.it)('creates chunks of size 2', () => {
|
|
14
|
+
node_assert_1.default.deepStrictEqual((0, splitChunks_1.splitChunks)('hello world', 2), ['he', 'll', 'o ', 'wo', 'rl', 'd']);
|
|
15
|
+
});
|
|
16
|
+
(0, node_test_1.it)('creates chunks of size 1', () => {
|
|
17
|
+
node_assert_1.default.deepStrictEqual((0, splitChunks_1.splitChunks)('hello world'), [
|
|
18
|
+
'h',
|
|
19
|
+
'e',
|
|
20
|
+
'l',
|
|
21
|
+
'l',
|
|
22
|
+
'o',
|
|
23
|
+
' ',
|
|
24
|
+
'w',
|
|
25
|
+
'o',
|
|
26
|
+
'r',
|
|
27
|
+
'l',
|
|
28
|
+
'd',
|
|
29
|
+
]);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_test_1 = require("node:test");
|
|
7
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
8
|
+
const stringCombinations_1 = require("../../transformations/stringCombinations");
|
|
9
|
+
(0, node_test_1.describe)('stringCombinations', () => {
|
|
10
|
+
(0, node_test_1.it)('returns correct combinations for 2 characters', () => {
|
|
11
|
+
const expected = ['', 'a', 'b', 'ab'];
|
|
12
|
+
node_assert_1.default.deepStrictEqual((0, stringCombinations_1.stringCombinations)('ab').sort(), expected.sort());
|
|
13
|
+
});
|
|
14
|
+
(0, node_test_1.it)('returns correct combinations for 3 unique characters', () => {
|
|
15
|
+
const expected = ['', 'a', 'b', 'c', 'ab', 'ac', 'bc', 'abc'];
|
|
16
|
+
node_assert_1.default.deepStrictEqual((0, stringCombinations_1.stringCombinations)('abc').sort(), expected.sort());
|
|
17
|
+
});
|
|
18
|
+
(0, node_test_1.it)('handles repeated characters correctly', () => {
|
|
19
|
+
const expected = ['', 'a', 'b', 'aa', 'ab', 'aab'];
|
|
20
|
+
node_assert_1.default.deepStrictEqual((0, stringCombinations_1.stringCombinations)('aab').sort(), expected.sort());
|
|
21
|
+
});
|
|
22
|
+
(0, node_test_1.it)('returns only empty string for empty input', () => {
|
|
23
|
+
node_assert_1.default.deepStrictEqual((0, stringCombinations_1.stringCombinations)(''), ['']);
|
|
24
|
+
});
|
|
25
|
+
(0, node_test_1.it)('handles single character input', () => {
|
|
26
|
+
node_assert_1.default.deepStrictEqual((0, stringCombinations_1.stringCombinations)('a'), ['', 'a']);
|
|
27
|
+
});
|
|
28
|
+
(0, node_test_1.it)('is case-sensitive', () => {
|
|
29
|
+
const expected = ['', 'A', 'b', 'Ab'];
|
|
30
|
+
node_assert_1.default.deepStrictEqual((0, stringCombinations_1.stringCombinations)('Ab').sort(), expected.sort());
|
|
31
|
+
});
|
|
32
|
+
(0, node_test_1.it)('handles special characters correctly', () => {
|
|
33
|
+
const expected = ['', '!', '@', '!@'];
|
|
34
|
+
node_assert_1.default.deepStrictEqual((0, stringCombinations_1.stringCombinations)('!@').sort(), expected.sort());
|
|
35
|
+
});
|
|
36
|
+
(0, node_test_1.it)('throws an error if input is not a string', () => {
|
|
37
|
+
node_assert_1.default.throws(() => (0, stringCombinations_1.stringCombinations)(123), /Input must be a string/);
|
|
38
|
+
node_assert_1.default.throws(() => (0, stringCombinations_1.stringCombinations)(null), /Input must be a string/);
|
|
39
|
+
node_assert_1.default.throws(() => (0, stringCombinations_1.stringCombinations)(undefined), /Input must be a string/);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_test_1 = require("node:test");
|
|
7
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
8
|
+
const stringPermutations_1 = require("../../transformations/stringPermutations");
|
|
9
|
+
(0, node_test_1.describe)('stringPermutations', () => {
|
|
10
|
+
(0, node_test_1.it)('returns correct permutations for small strings', () => {
|
|
11
|
+
node_assert_1.default.deepStrictEqual((0, stringPermutations_1.stringPermutations)('ab').sort(), ['ab', 'ba'].sort());
|
|
12
|
+
});
|
|
13
|
+
(0, node_test_1.it)('returns all permutations for 3 unique characters', () => {
|
|
14
|
+
const expected = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba'];
|
|
15
|
+
node_assert_1.default.deepStrictEqual((0, stringPermutations_1.stringPermutations)('abc').sort(), expected.sort());
|
|
16
|
+
});
|
|
17
|
+
(0, node_test_1.it)('handles repeated characters correctly', () => {
|
|
18
|
+
const expected = ['aab', 'aba', 'baa'];
|
|
19
|
+
node_assert_1.default.deepStrictEqual((0, stringPermutations_1.stringPermutations)('aab').sort(), expected.sort());
|
|
20
|
+
});
|
|
21
|
+
(0, node_test_1.it)('handles single character input', () => {
|
|
22
|
+
node_assert_1.default.deepStrictEqual((0, stringPermutations_1.stringPermutations)('a'), ['a']);
|
|
23
|
+
});
|
|
24
|
+
(0, node_test_1.it)('handles empty string input', () => {
|
|
25
|
+
node_assert_1.default.deepStrictEqual((0, stringPermutations_1.stringPermutations)(''), ['']);
|
|
26
|
+
});
|
|
27
|
+
(0, node_test_1.it)('is case-sensitive', () => {
|
|
28
|
+
const expected = ['Ab', 'bA'];
|
|
29
|
+
node_assert_1.default.deepStrictEqual((0, stringPermutations_1.stringPermutations)('Ab').sort(), expected.sort());
|
|
30
|
+
});
|
|
31
|
+
(0, node_test_1.it)('handles special characters', () => {
|
|
32
|
+
const expected = ['!@', '@!'];
|
|
33
|
+
node_assert_1.default.deepStrictEqual((0, stringPermutations_1.stringPermutations)('!@').sort(), expected.sort());
|
|
34
|
+
});
|
|
35
|
+
(0, node_test_1.it)('throws an error if input is not a string', () => {
|
|
36
|
+
node_assert_1.default.throws(() => (0, stringPermutations_1.stringPermutations)(123), /Input must be a string/);
|
|
37
|
+
node_assert_1.default.throws(() => (0, stringPermutations_1.stringPermutations)(null), /Input must be a string/);
|
|
38
|
+
node_assert_1.default.throws(() => (0, stringPermutations_1.stringPermutations)(undefined), /Input must be a string/);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_test_1 = require("node:test");
|
|
7
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
8
|
+
const isAlphaNumeric_1 = require("../../validations/isAlphaNumeric");
|
|
9
|
+
(0, node_test_1.describe)('isAlphaNumeric', () => {
|
|
10
|
+
(0, node_test_1.it)('returns true for alphanumeric strings', () => {
|
|
11
|
+
node_assert_1.default.strictEqual((0, isAlphaNumeric_1.isAlphaNumeric)('abc123'), true);
|
|
12
|
+
node_assert_1.default.strictEqual((0, isAlphaNumeric_1.isAlphaNumeric)('A1B2C3'), true);
|
|
13
|
+
node_assert_1.default.strictEqual((0, isAlphaNumeric_1.isAlphaNumeric)('123'), true);
|
|
14
|
+
node_assert_1.default.strictEqual((0, isAlphaNumeric_1.isAlphaNumeric)('abc'), true);
|
|
15
|
+
});
|
|
16
|
+
(0, node_test_1.it)('returns false for strings with special characters or spaces', () => {
|
|
17
|
+
node_assert_1.default.strictEqual((0, isAlphaNumeric_1.isAlphaNumeric)('abc!123'), false);
|
|
18
|
+
node_assert_1.default.strictEqual((0, isAlphaNumeric_1.isAlphaNumeric)('hello world'), false);
|
|
19
|
+
node_assert_1.default.strictEqual((0, isAlphaNumeric_1.isAlphaNumeric)('test@'), false);
|
|
20
|
+
});
|
|
21
|
+
(0, node_test_1.it)('returns false for empty string', () => {
|
|
22
|
+
node_assert_1.default.strictEqual((0, isAlphaNumeric_1.isAlphaNumeric)(''), false);
|
|
23
|
+
});
|
|
24
|
+
(0, node_test_1.it)('throws an error if input is not a string', () => {
|
|
25
|
+
node_assert_1.default.throws(() => (0, isAlphaNumeric_1.isAlphaNumeric)(123), /Input must be a string/);
|
|
26
|
+
node_assert_1.default.throws(() => (0, isAlphaNumeric_1.isAlphaNumeric)(null), /Input must be a string/);
|
|
27
|
+
node_assert_1.default.throws(() => (0, isAlphaNumeric_1.isAlphaNumeric)(undefined), /Input must be a string/);
|
|
28
|
+
node_assert_1.default.throws(() => (0, isAlphaNumeric_1.isAlphaNumeric)({}), /Input must be a string/);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_test_1 = require("node:test");
|
|
7
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
8
|
+
const isAlphabetic_1 = require("../../validations/isAlphabetic");
|
|
9
|
+
(0, node_test_1.describe)('isAlphabetic', () => {
|
|
10
|
+
(0, node_test_1.it)('returns true for purely alphabetic strings', () => {
|
|
11
|
+
node_assert_1.default.strictEqual((0, isAlphabetic_1.isAlphabetic)('hello'), true);
|
|
12
|
+
node_assert_1.default.strictEqual((0, isAlphabetic_1.isAlphabetic)('World'), true);
|
|
13
|
+
node_assert_1.default.strictEqual((0, isAlphabetic_1.isAlphabetic)('TestCase'), true);
|
|
14
|
+
});
|
|
15
|
+
(0, node_test_1.it)('returns false for strings with numbers', () => {
|
|
16
|
+
node_assert_1.default.strictEqual((0, isAlphabetic_1.isAlphabetic)('hello123'), false);
|
|
17
|
+
node_assert_1.default.strictEqual((0, isAlphabetic_1.isAlphabetic)('Test1'), false);
|
|
18
|
+
});
|
|
19
|
+
(0, node_test_1.it)('returns false for strings with special characters or spaces', () => {
|
|
20
|
+
node_assert_1.default.strictEqual((0, isAlphabetic_1.isAlphabetic)('hello!'), false);
|
|
21
|
+
node_assert_1.default.strictEqual((0, isAlphabetic_1.isAlphabetic)('hello world'), false);
|
|
22
|
+
node_assert_1.default.strictEqual((0, isAlphabetic_1.isAlphabetic)('Hi-There'), false);
|
|
23
|
+
});
|
|
24
|
+
(0, node_test_1.it)('returns false for empty strings', () => {
|
|
25
|
+
node_assert_1.default.strictEqual((0, isAlphabetic_1.isAlphabetic)(''), false);
|
|
26
|
+
});
|
|
27
|
+
(0, node_test_1.it)('throws an error if input is not a string', () => {
|
|
28
|
+
node_assert_1.default.throws(() => (0, isAlphabetic_1.isAlphabetic)(123), /Input must be a string/);
|
|
29
|
+
node_assert_1.default.throws(() => (0, isAlphabetic_1.isAlphabetic)(null), /Input must be a string/);
|
|
30
|
+
node_assert_1.default.throws(() => (0, isAlphabetic_1.isAlphabetic)(undefined), /Input must be a string/);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_test_1 = require("node:test");
|
|
7
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
8
|
+
const isAnagram_1 = require("../../validations/isAnagram");
|
|
9
|
+
(0, node_test_1.describe)('isAnagram', () => {
|
|
10
|
+
(0, node_test_1.it)('returns true for valid anagrams (simple lowercase words)', () => {
|
|
11
|
+
node_assert_1.default.strictEqual((0, isAnagram_1.isAnagram)('listen', 'silent'), true);
|
|
12
|
+
node_assert_1.default.strictEqual((0, isAnagram_1.isAnagram)('evil', 'vile'), true);
|
|
13
|
+
});
|
|
14
|
+
(0, node_test_1.it)('returns true for case-insensitive matches', () => {
|
|
15
|
+
node_assert_1.default.strictEqual((0, isAnagram_1.isAnagram)('Listen', 'Silent'), true);
|
|
16
|
+
node_assert_1.default.strictEqual((0, isAnagram_1.isAnagram)('Debit Card', 'Bad Credit'), true);
|
|
17
|
+
});
|
|
18
|
+
(0, node_test_1.it)('returns true when ignoring spaces and punctuation', () => {
|
|
19
|
+
node_assert_1.default.strictEqual((0, isAnagram_1.isAnagram)('Astronomer', 'Moon starer'), true);
|
|
20
|
+
node_assert_1.default.strictEqual((0, isAnagram_1.isAnagram)('The eyes!!', 'They see'), true);
|
|
21
|
+
});
|
|
22
|
+
(0, node_test_1.it)('returns false for non-anagrams', () => {
|
|
23
|
+
node_assert_1.default.strictEqual((0, isAnagram_1.isAnagram)('hello', 'world'), false);
|
|
24
|
+
node_assert_1.default.strictEqual((0, isAnagram_1.isAnagram)('abc', 'abcd'), false);
|
|
25
|
+
});
|
|
26
|
+
(0, node_test_1.it)('returns true for single character anagrams', () => {
|
|
27
|
+
node_assert_1.default.strictEqual((0, isAnagram_1.isAnagram)('a', 'a'), true);
|
|
28
|
+
});
|
|
29
|
+
(0, node_test_1.it)('returns false for different single characters', () => {
|
|
30
|
+
node_assert_1.default.strictEqual((0, isAnagram_1.isAnagram)('a', 'b'), false);
|
|
31
|
+
});
|
|
32
|
+
(0, node_test_1.it)('returns true for empty strings (both empty)', () => {
|
|
33
|
+
node_assert_1.default.strictEqual((0, isAnagram_1.isAnagram)('', ''), true);
|
|
34
|
+
});
|
|
35
|
+
(0, node_test_1.it)('returns false when only one string is empty', () => {
|
|
36
|
+
node_assert_1.default.strictEqual((0, isAnagram_1.isAnagram)('', 'a'), false);
|
|
37
|
+
node_assert_1.default.strictEqual((0, isAnagram_1.isAnagram)('a', ''), false);
|
|
38
|
+
});
|
|
39
|
+
(0, node_test_1.it)('throws an error if inputs are not strings', () => {
|
|
40
|
+
node_assert_1.default.throws(() => (0, isAnagram_1.isAnagram)(123, 'abc'), /Both inputs must be strings/);
|
|
41
|
+
node_assert_1.default.throws(() => (0, isAnagram_1.isAnagram)(null, 'abc'), /Both inputs must be strings/);
|
|
42
|
+
node_assert_1.default.throws(() => (0, isAnagram_1.isAnagram)(undefined, 'abc'), /Both inputs must be strings/);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_test_1 = require("node:test");
|
|
7
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
8
|
+
const isCoordinates_1 = require("../../validations/isCoordinates");
|
|
9
|
+
(0, node_test_1.describe)('isCoordinates', () => {
|
|
10
|
+
(0, node_test_1.it)('returns true for valid coordinates', () => {
|
|
11
|
+
node_assert_1.default.strictEqual((0, isCoordinates_1.isCoordinates)(48.8582, 2.2945), true);
|
|
12
|
+
node_assert_1.default.strictEqual((0, isCoordinates_1.isCoordinates)(40.748817, -73.985428), true);
|
|
13
|
+
});
|
|
14
|
+
(0, node_test_1.it)('returns false for invalid coordinates', () => {
|
|
15
|
+
node_assert_1.default.strictEqual((0, isCoordinates_1.isCoordinates)(200, 200), false);
|
|
16
|
+
node_assert_1.default.strictEqual((0, isCoordinates_1.isCoordinates)(-200, -200), false);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_test_1 = require("node:test");
|
|
7
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
8
|
+
const isEmail_1 = require("../../validations/isEmail");
|
|
9
|
+
(0, node_test_1.describe)('isEmail (SMTPUTF8)', () => {
|
|
10
|
+
(0, node_test_1.it)('accepts emoji in local-part by default', () => {
|
|
11
|
+
node_assert_1.default.strictEqual((0, isEmail_1.isEmail)('I❤️CHOCOLATE@example.com'), true);
|
|
12
|
+
});
|
|
13
|
+
(0, node_test_1.it)('rejects emoji in local-part when smtpUTF8 is explicitly disabled', () => {
|
|
14
|
+
node_assert_1.default.strictEqual((0, isEmail_1.isEmail)('I❤️CHOCOLATE@example.com', { smtpUTF8: false }), false);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -6,12 +6,62 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const node_test_1 = require("node:test");
|
|
7
7
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
8
8
|
const isEmail_1 = require("../../validations/isEmail");
|
|
9
|
-
(0, node_test_1.describe)(
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
(0, node_test_1.describe)("isEmail", () => {
|
|
10
|
+
//
|
|
11
|
+
// ✅ Basic valid emails
|
|
12
|
+
//
|
|
13
|
+
(0, node_test_1.it)("returns true for basic valid emails", () => {
|
|
14
|
+
node_assert_1.default.strictEqual((0, isEmail_1.isEmail)("foo@bar.com"), true);
|
|
15
|
+
node_assert_1.default.strictEqual((0, isEmail_1.isEmail)("test@example.org"), true);
|
|
16
|
+
node_assert_1.default.strictEqual((0, isEmail_1.isEmail)("very.common@example.com"), true);
|
|
17
|
+
node_assert_1.default.strictEqual((0, isEmail_1.isEmail)("long.email-address-with-hyphens@and.subdomains.example.com"), true);
|
|
12
18
|
});
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
//
|
|
20
|
+
// ✅ Special characters in local-part
|
|
21
|
+
//
|
|
22
|
+
(0, node_test_1.it)("returns true for special characters", () => {
|
|
23
|
+
node_assert_1.default.strictEqual((0, isEmail_1.isEmail)("test+tag@example.com"), true);
|
|
24
|
+
node_assert_1.default.strictEqual((0, isEmail_1.isEmail)("user.name+tag+sorting@example.com"), true);
|
|
25
|
+
node_assert_1.default.strictEqual((0, isEmail_1.isEmail)("test/test@example.com"), true);
|
|
26
|
+
});
|
|
27
|
+
//
|
|
28
|
+
// ✅ IPv4 address literal
|
|
29
|
+
//
|
|
30
|
+
(0, node_test_1.it)("returns true for IPv4 address literal", () => {
|
|
31
|
+
node_assert_1.default.strictEqual((0, isEmail_1.isEmail)("user@[192.168.1.1]"), true);
|
|
32
|
+
});
|
|
33
|
+
//
|
|
34
|
+
// ✅ Quoted local-parts (RFC 5322)
|
|
35
|
+
//
|
|
36
|
+
(0, node_test_1.it)("returns true for quoted local-parts", () => {
|
|
37
|
+
node_assert_1.default.strictEqual((0, isEmail_1.isEmail)('"much.more unusual"@example.com'), true);
|
|
38
|
+
node_assert_1.default.strictEqual((0, isEmail_1.isEmail)('"very.unusual.@.unusual.com"@example.com'), true);
|
|
39
|
+
node_assert_1.default.strictEqual((0, isEmail_1.isEmail)('"very.(),:;<>[]".VERY."very@\\ "very".unusual"@strange.example.com'), true);
|
|
40
|
+
});
|
|
41
|
+
//
|
|
42
|
+
// ✅ IPv6 domain literal
|
|
43
|
+
//
|
|
44
|
+
(0, node_test_1.it)("returns true for IPv6 domain literals", () => {
|
|
45
|
+
node_assert_1.default.strictEqual((0, isEmail_1.isEmail)("user@[IPv6:2001:db8::1]"), true);
|
|
46
|
+
});
|
|
47
|
+
//
|
|
48
|
+
// ❌ Invalid emails
|
|
49
|
+
//
|
|
50
|
+
(0, node_test_1.it)("returns false for invalid emails", () => {
|
|
51
|
+
node_assert_1.default.strictEqual((0, isEmail_1.isEmail)(""), false);
|
|
52
|
+
node_assert_1.default.strictEqual((0, isEmail_1.isEmail)("@example.com"), false);
|
|
53
|
+
node_assert_1.default.strictEqual((0, isEmail_1.isEmail)("test@"), false);
|
|
54
|
+
node_assert_1.default.strictEqual((0, isEmail_1.isEmail)("test"), false);
|
|
55
|
+
node_assert_1.default.strictEqual((0, isEmail_1.isEmail)("test@.com"), false);
|
|
56
|
+
node_assert_1.default.strictEqual((0, isEmail_1.isEmail)("test..test@example.com"), false);
|
|
57
|
+
node_assert_1.default.strictEqual((0, isEmail_1.isEmail)(".test@example.com"), false);
|
|
58
|
+
node_assert_1.default.strictEqual((0, isEmail_1.isEmail)("test.@example.com"), false);
|
|
59
|
+
});
|
|
60
|
+
//
|
|
61
|
+
// ❌ Invalid quoted emails
|
|
62
|
+
//
|
|
63
|
+
(0, node_test_1.it)("returns false for invalid quoted local-parts", () => {
|
|
64
|
+
node_assert_1.default.strictEqual((0, isEmail_1.isEmail)('"unclosed-quote@example.com'), false);
|
|
65
|
+
node_assert_1.default.strictEqual((0, isEmail_1.isEmail)('"missing"quotes@@example.com'), false);
|
|
16
66
|
});
|
|
17
67
|
});
|
|
@@ -6,27 +6,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const node_test_1 = require("node:test");
|
|
7
7
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
8
8
|
const isHexColor_1 = require("../../validations/isHexColor");
|
|
9
|
-
(0, node_test_1.describe)(
|
|
10
|
-
(0, node_test_1.it)(
|
|
11
|
-
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)(
|
|
12
|
-
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)(
|
|
13
|
-
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)(
|
|
14
|
-
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)(
|
|
15
|
-
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)(
|
|
16
|
-
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)(
|
|
9
|
+
(0, node_test_1.describe)('isHexColor', () => {
|
|
10
|
+
(0, node_test_1.it)('returns true for valid hex colors', () => {
|
|
11
|
+
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)('#abc'), true);
|
|
12
|
+
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)('abc'), true);
|
|
13
|
+
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)('#a1b2c3'), true);
|
|
14
|
+
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)('a1b2c3'), true);
|
|
15
|
+
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)('#A1B2C3'), true);
|
|
16
|
+
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)(' #fff '), true);
|
|
17
17
|
});
|
|
18
|
-
(0, node_test_1.it)(
|
|
19
|
-
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)(
|
|
20
|
-
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)(
|
|
21
|
-
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)(
|
|
22
|
-
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)(
|
|
23
|
-
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)(
|
|
24
|
-
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)(
|
|
25
|
-
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)(
|
|
26
|
-
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)(
|
|
27
|
-
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)(
|
|
28
|
-
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)(
|
|
29
|
-
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)(
|
|
30
|
-
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)(
|
|
18
|
+
(0, node_test_1.it)('returns false for invalid hex colors', () => {
|
|
19
|
+
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)('#12G'), false);
|
|
20
|
+
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)('xyz'), false);
|
|
21
|
+
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)('#ab'), false);
|
|
22
|
+
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)('#12345'), false);
|
|
23
|
+
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)('12345'), false);
|
|
24
|
+
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)('#1234567'), false);
|
|
25
|
+
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)('1234567'), false);
|
|
26
|
+
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)('#1234g6'), false);
|
|
27
|
+
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)('1234g6'), false);
|
|
28
|
+
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)(''), false);
|
|
29
|
+
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)(' '), false);
|
|
30
|
+
node_assert_1.default.strictEqual((0, isHexColor_1.isHexColor)('blue'), false);
|
|
31
31
|
});
|
|
32
32
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|