@rogolev/value 0.0.1 → 0.0.2
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 -4
- package/CHANGELOG.md +68 -56
- package/LICENSE +41 -41
- package/README.md +100 -91
- package/babel.config.json +20 -20
- package/docs/classes/Convert/toArray.md +100 -0
- package/docs/classes/Convert/toAssoc.md +90 -0
- package/docs/classes/Convert/toBool.md +72 -0
- package/docs/classes/Convert/toBoolean.md +72 -0
- package/docs/classes/Convert/toFloat.md +69 -0
- package/docs/classes/Convert/toInt.md +86 -0
- package/docs/classes/Convert/toInteger.md +86 -0
- package/docs/classes/Convert/toList.md +73 -0
- package/docs/classes/Convert/toObject.md +76 -0
- package/docs/classes/Convert/toString.md +125 -0
- package/docs/classes/Convert.md +44 -0
- package/docs/classes/Type/isArray.md +106 -0
- package/docs/classes/Type/isAssoc.md +57 -0
- package/docs/classes/Type/isBigInt.md +49 -0
- package/docs/classes/Type/isBool.md +51 -0
- package/docs/classes/Type/isBoolean.md +51 -0
- package/docs/classes/Type/isClass.md +60 -0
- package/docs/classes/Type/isEmpty.md +53 -0
- package/docs/classes/Type/isFloat.md +77 -0
- package/docs/classes/Type/isFunction.md +64 -0
- package/docs/classes/Type/isInfinity.md +59 -0
- package/docs/classes/Type/isInt.md +77 -0
- package/docs/classes/Type/isInteger.md +77 -0
- package/docs/classes/Type/isList.md +49 -0
- package/docs/classes/Type/isNaN.md +57 -0
- package/docs/classes/Type/isNull.md +49 -0
- package/docs/classes/Type/isNumber.md +60 -0
- package/docs/classes/Type/isNumeric.md +58 -0
- package/docs/classes/Type/isObject.md +53 -0
- package/docs/classes/Type/isScalar.md +54 -0
- package/docs/classes/Type/isString.md +54 -0
- package/docs/classes/Type/isSymbol.md +56 -0
- package/docs/classes/Type/isUndefined.md +52 -0
- package/docs/classes/Type.md +74 -0
- package/docs/classes.md +9 -0
- package/docs/helpers/array.md +80 -80
- package/docs/helpers/empty.md +77 -77
- package/docs/helpers/gettype.md +69 -69
- package/docs/helpers/is_array.md +105 -105
- package/docs/helpers/is_assoc.md +59 -59
- package/docs/helpers/is_bigint.md +57 -57
- package/docs/helpers/is_bool.md +50 -50
- package/docs/helpers/is_boolean.md +50 -50
- package/docs/helpers/is_class.md +73 -73
- package/docs/helpers/is_float.md +71 -71
- package/docs/helpers/is_function.md +62 -62
- package/docs/helpers/is_infinity.md +61 -61
- package/docs/helpers/is_int.md +81 -81
- package/docs/helpers/is_integer.md +82 -82
- package/docs/helpers/is_list.md +51 -51
- package/docs/helpers/is_nan.md +59 -59
- package/docs/helpers/is_null.md +49 -49
- package/docs/helpers/is_number.md +67 -67
- package/docs/helpers/is_numeric.md +76 -76
- package/docs/helpers/is_object.md +69 -69
- package/docs/helpers/is_scalar.md +60 -60
- package/docs/helpers/is_string.md +58 -58
- package/docs/helpers/is_symbol.md +58 -58
- package/docs/helpers/is_undefined.md +56 -56
- package/docs/helpers/print.md +187 -187
- package/docs/helpers/print_type.md +225 -225
- package/docs/helpers/settype.md +78 -78
- package/docs/helpers/to_array.md +106 -106
- package/docs/helpers/to_assoc.md +91 -91
- package/docs/helpers/to_bool.md +76 -76
- package/docs/helpers/to_boolean.md +77 -77
- package/docs/helpers/to_float.md +70 -70
- package/docs/helpers/to_int.md +87 -87
- package/docs/helpers/to_integer.md +87 -87
- package/docs/helpers/to_list.md +47 -47
- package/docs/helpers/to_object.md +76 -76
- package/docs/helpers/to_string.md +134 -134
- package/docs/helpers.md +51 -51
- package/docs/types/NaN.md +30 -30
- package/docs/types/array.md +252 -252
- package/docs/types/bigint.md +34 -34
- package/docs/types/boolean.md +47 -47
- package/docs/types/class.md +36 -36
- package/docs/types/float.md +35 -35
- package/docs/types/function.md +121 -121
- package/docs/types/infinity.md +32 -32
- package/docs/types/integer.md +35 -35
- package/docs/types/null.md +23 -23
- package/docs/types/object.md +62 -62
- package/docs/types/string.md +33 -33
- package/docs/types/symbol.md +29 -29
- package/docs/types/undefined.md +25 -25
- package/docs/types.md +44 -44
- package/eslint.config.mjs +1664 -1664
- package/index.mjs +40 -37
- package/jest.config.mjs +31 -31
- package/package.json +48 -47
- package/prettier.config.mjs +224 -224
- package/src/classes/Convert.mjs +819 -0
- package/src/classes/Type.mjs +1285 -0
- package/src/helpers/array.mjs +107 -107
- package/src/helpers/empty.mjs +70 -70
- package/src/helpers/gettype.mjs +133 -133
- package/src/helpers/is_array.mjs +128 -128
- package/src/helpers/is_assoc.mjs +51 -51
- package/src/helpers/is_bigint.mjs +47 -47
- package/src/helpers/is_bool.mjs +43 -43
- package/src/helpers/is_boolean.mjs +43 -43
- package/src/helpers/is_class.mjs +87 -87
- package/src/helpers/is_float.mjs +67 -67
- package/src/helpers/is_function.mjs +74 -74
- package/src/helpers/is_infinity.mjs +52 -52
- package/src/helpers/is_int.mjs +57 -57
- package/src/helpers/is_integer.mjs +74 -74
- package/src/helpers/is_list.mjs +43 -43
- package/src/helpers/is_nan.mjs +51 -51
- package/src/helpers/is_null.mjs +37 -37
- package/src/helpers/is_number.mjs +49 -49
- package/src/helpers/is_numeric.mjs +64 -64
- package/src/helpers/is_object.mjs +72 -72
- package/src/helpers/is_scalar.mjs +45 -45
- package/src/helpers/is_string.mjs +46 -46
- package/src/helpers/is_symbol.mjs +46 -46
- package/src/helpers/is_undefined.mjs +44 -44
- package/src/helpers/print.mjs +245 -245
- package/src/helpers/print_type.mjs +261 -261
- package/src/helpers/settype.mjs +101 -101
- package/src/helpers/to_array.mjs +118 -118
- package/src/helpers/to_assoc.mjs +98 -98
- package/src/helpers/to_bool.mjs +68 -68
- package/src/helpers/to_boolean.mjs +64 -64
- package/src/helpers/to_float.mjs +72 -72
- package/src/helpers/to_int.mjs +93 -93
- package/src/helpers/to_integer.mjs +81 -81
- package/src/helpers/to_list.mjs +56 -56
- package/src/helpers/to_object.mjs +94 -94
- package/src/helpers/to_string.mjs +157 -157
- package/tests/classes/Convert.test.mjs +399 -0
- package/tests/classes/Type.test.mjs +1263 -0
- package/tests/helpers/array.test.mjs +58 -58
- package/tests/helpers/empty.test.mjs +22 -22
- package/tests/helpers/gettype.test.mjs +74 -74
- package/tests/helpers/is_array.test.mjs +404 -404
- package/tests/helpers/is_assoc.test.mjs +42 -42
- package/tests/helpers/is_bigint.test.mjs +51 -51
- package/tests/helpers/is_bool.test.mjs +43 -43
- package/tests/helpers/is_boolean.test.mjs +43 -43
- package/tests/helpers/is_class.test.mjs +84 -84
- package/tests/helpers/is_float.test.mjs +87 -87
- package/tests/helpers/is_function.test.mjs +83 -83
- package/tests/helpers/is_infinity.test.mjs +46 -46
- package/tests/helpers/is_int.test.mjs +45 -45
- package/tests/helpers/is_integer.test.mjs +64 -64
- package/tests/helpers/is_list.test.mjs +42 -42
- package/tests/helpers/is_nan.test.mjs +43 -43
- package/tests/helpers/is_null.test.mjs +17 -17
- package/tests/helpers/is_number.test.mjs +25 -25
- package/tests/helpers/is_numeric.test.mjs +30 -30
- package/tests/helpers/is_object.test.mjs +52 -52
- package/tests/helpers/is_scalar.test.mjs +21 -21
- package/tests/helpers/is_string.test.mjs +20 -20
- package/tests/helpers/is_symbol.test.mjs +20 -20
- package/tests/helpers/is_undefined.test.mjs +18 -18
- package/tests/helpers/print.test.mjs +62 -62
- package/tests/helpers/print_type.test.mjs +62 -62
- package/tests/helpers/settype.test.mjs +34 -34
- package/tests/helpers/to_array.test.mjs +38 -38
- package/tests/helpers/to_assoc.test.mjs +33 -33
- package/tests/helpers/to_bool.test.mjs +51 -51
- package/tests/helpers/to_boolean.test.mjs +51 -51
- package/tests/helpers/to_float.test.mjs +26 -26
- package/tests/helpers/to_int.test.mjs +48 -48
- package/tests/helpers/to_integer.test.mjs +48 -48
- package/tests/helpers/to_list.test.mjs +32 -32
- package/tests/helpers/to_object.test.mjs +36 -36
- package/tests/helpers/to_string.test.mjs +71 -71
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import { expect, test, describe } from '@jest/globals';
|
|
2
|
-
import { array } from '../../index.mjs';
|
|
3
|
-
|
|
4
|
-
describe('Функция array', () => {
|
|
5
|
-
test('Должна возвращать массив с единственным элементом, если передан один массив', () => {
|
|
6
|
-
const input = [1, 2, 3];
|
|
7
|
-
const result = array(input);
|
|
8
|
-
expect(result).toEqual([1, 2, 3]);
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
test('Должна добавлять элементы в массив, если передано несколько значений', () => {
|
|
12
|
-
const result = array(1, [2, 3], { a: 10, b: 20 });
|
|
13
|
-
expect(result).toEqual([1, [2, 3], { a: 10, b: 20 }]);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
test('Должна обрабатывать ассоциативные массивы (объекты с ключами и значениями)', () => {
|
|
17
|
-
const assoc = { key1: 'value1', key2: 'value2' };
|
|
18
|
-
const result = array(assoc);
|
|
19
|
-
expect(result).toEqual(assoc); // Элемент должен быть объектом
|
|
20
|
-
expect(Object.getPrototypeOf(result)).toBeNull(); // Прототип должен быть null
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test('Должна создавать итератор для ассоциативного массива', () => {
|
|
24
|
-
const assoc = { key: 'value', anotherKey: 'anotherValue' };
|
|
25
|
-
const result = array(assoc);
|
|
26
|
-
|
|
27
|
-
const iteratorOutput = [];
|
|
28
|
-
for (const [key, value] of result) {
|
|
29
|
-
iteratorOutput.push([key, value]);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
expect(iteratorOutput).toEqual([
|
|
33
|
-
['key', 'value'],
|
|
34
|
-
['anotherKey', 'anotherValue'],
|
|
35
|
-
]);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test('Должна возвращать исходный массив, если он передан как единственный аргумент', () => {
|
|
39
|
-
const nestedArray = [1, 2, 3];
|
|
40
|
-
const result = array(nestedArray);
|
|
41
|
-
expect(result).toBe(nestedArray); // Массив должен быть возвращен напрямую
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
test('Должна работать с примитивными значениями', () => {
|
|
45
|
-
const result = array(42, 'test', true, null);
|
|
46
|
-
expect(result).toEqual([42, 'test', true, null]);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test('Должна возвращать массив, если передано несколько различных типов', () => {
|
|
50
|
-
const result = array(1, 'text', [2, 3], { foo: 'bar' });
|
|
51
|
-
expect(result).toEqual([1, 'text', [2, 3], { foo: 'bar' }]);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test('Должна возвращать массив с объектами и ассоциативными массивами', () => {
|
|
55
|
-
const result = array({ key1: 'value1' }, [1, 2], { key2: 'value2' });
|
|
56
|
-
expect(result).toEqual([{ key1: 'value1' }, [1, 2], { key2: 'value2' }]);
|
|
57
|
-
});
|
|
58
|
-
});
|
|
1
|
+
import { expect, test, describe } from '@jest/globals';
|
|
2
|
+
import { array } from '../../index.mjs';
|
|
3
|
+
|
|
4
|
+
describe('Функция array', () => {
|
|
5
|
+
test('Должна возвращать массив с единственным элементом, если передан один массив', () => {
|
|
6
|
+
const input = [1, 2, 3];
|
|
7
|
+
const result = array(input);
|
|
8
|
+
expect(result).toEqual([1, 2, 3]);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test('Должна добавлять элементы в массив, если передано несколько значений', () => {
|
|
12
|
+
const result = array(1, [2, 3], { a: 10, b: 20 });
|
|
13
|
+
expect(result).toEqual([1, [2, 3], { a: 10, b: 20 }]);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test('Должна обрабатывать ассоциативные массивы (объекты с ключами и значениями)', () => {
|
|
17
|
+
const assoc = { key1: 'value1', key2: 'value2' };
|
|
18
|
+
const result = array(assoc);
|
|
19
|
+
expect(result).toEqual(assoc); // Элемент должен быть объектом
|
|
20
|
+
expect(Object.getPrototypeOf(result)).toBeNull(); // Прототип должен быть null
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('Должна создавать итератор для ассоциативного массива', () => {
|
|
24
|
+
const assoc = { key: 'value', anotherKey: 'anotherValue' };
|
|
25
|
+
const result = array(assoc);
|
|
26
|
+
|
|
27
|
+
const iteratorOutput = [];
|
|
28
|
+
for (const [key, value] of result) {
|
|
29
|
+
iteratorOutput.push([key, value]);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
expect(iteratorOutput).toEqual([
|
|
33
|
+
['key', 'value'],
|
|
34
|
+
['anotherKey', 'anotherValue'],
|
|
35
|
+
]);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('Должна возвращать исходный массив, если он передан как единственный аргумент', () => {
|
|
39
|
+
const nestedArray = [1, 2, 3];
|
|
40
|
+
const result = array(nestedArray);
|
|
41
|
+
expect(result).toBe(nestedArray); // Массив должен быть возвращен напрямую
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('Должна работать с примитивными значениями', () => {
|
|
45
|
+
const result = array(42, 'test', true, null);
|
|
46
|
+
expect(result).toEqual([42, 'test', true, null]);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('Должна возвращать массив, если передано несколько различных типов', () => {
|
|
50
|
+
const result = array(1, 'text', [2, 3], { foo: 'bar' });
|
|
51
|
+
expect(result).toEqual([1, 'text', [2, 3], { foo: 'bar' }]);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('Должна возвращать массив с объектами и ассоциативными массивами', () => {
|
|
55
|
+
const result = array({ key1: 'value1' }, [1, 2], { key2: 'value2' });
|
|
56
|
+
expect(result).toEqual([{ key1: 'value1' }, [1, 2], { key2: 'value2' }]);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { expect, test, describe } from '@jest/globals';
|
|
2
|
-
import { empty } from '../../index.mjs';
|
|
3
|
-
|
|
4
|
-
describe('Функция empty', () => {
|
|
5
|
-
test('Должна возвращать true для пустых значений', () => {
|
|
6
|
-
expect(empty(null)).toBe(true);
|
|
7
|
-
expect(empty(undefined)).toBe(true);
|
|
8
|
-
expect(empty('')).toBe(true);
|
|
9
|
-
expect(empty(0)).toBe(true);
|
|
10
|
-
expect(empty(false)).toBe(true);
|
|
11
|
-
expect(empty([])).toBe(true);
|
|
12
|
-
expect(empty({})).toBe(true);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
test('Должна возвращать false для непустых значений', () => {
|
|
16
|
-
expect(empty('example')).toBe(false);
|
|
17
|
-
expect(empty(123)).toBe(false);
|
|
18
|
-
expect(empty(true)).toBe(false);
|
|
19
|
-
expect(empty([1, 2, 3])).toBe(false);
|
|
20
|
-
expect(empty({ key: 'value' })).toBe(false);
|
|
21
|
-
});
|
|
22
|
-
});
|
|
1
|
+
import { expect, test, describe } from '@jest/globals';
|
|
2
|
+
import { empty } from '../../index.mjs';
|
|
3
|
+
|
|
4
|
+
describe('Функция empty', () => {
|
|
5
|
+
test('Должна возвращать true для пустых значений', () => {
|
|
6
|
+
expect(empty(null)).toBe(true);
|
|
7
|
+
expect(empty(undefined)).toBe(true);
|
|
8
|
+
expect(empty('')).toBe(true);
|
|
9
|
+
expect(empty(0)).toBe(true);
|
|
10
|
+
expect(empty(false)).toBe(true);
|
|
11
|
+
expect(empty([])).toBe(true);
|
|
12
|
+
expect(empty({})).toBe(true);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('Должна возвращать false для непустых значений', () => {
|
|
16
|
+
expect(empty('example')).toBe(false);
|
|
17
|
+
expect(empty(123)).toBe(false);
|
|
18
|
+
expect(empty(true)).toBe(false);
|
|
19
|
+
expect(empty([1, 2, 3])).toBe(false);
|
|
20
|
+
expect(empty({ key: 'value' })).toBe(false);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
import { expect, test } from '@jest/globals';
|
|
2
|
-
import { gettype } from '../../index.mjs';
|
|
3
|
-
|
|
4
|
-
describe('Функция gettype', () => {
|
|
5
|
-
test('должна возвращать "null" для null', () => {
|
|
6
|
-
expect(gettype(null)).toBe('null');
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
test('должна возвращать "NaN" для NaN', () => {
|
|
10
|
-
expect(gettype(NaN)).toBe('NaN');
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
test('должна возвращать "undefined" для undefined', () => {
|
|
14
|
-
expect(gettype(undefined)).toBe('undefined');
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
test('должна возвращать "infinity" для Infinity и -Infinity', () => {
|
|
18
|
-
expect(gettype(Infinity)).toBe('infinity');
|
|
19
|
-
expect(gettype(-Infinity)).toBe('infinity');
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test('должна возвращать "boolean" для логических значений', () => {
|
|
23
|
-
expect(gettype(true)).toBe('boolean');
|
|
24
|
-
expect(gettype(false)).toBe('boolean');
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test('должна возвращать "integer" для целых чисел', () => {
|
|
28
|
-
expect(gettype(42)).toBe('integer');
|
|
29
|
-
expect(gettype(-42)).toBe('integer');
|
|
30
|
-
expect(gettype(0)).toBe('integer');
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
test('должна возвращать "bigint" для значений типа BigInt', () => {
|
|
34
|
-
expect(gettype(BigInt(123456))).toBe('bigint');
|
|
35
|
-
expect(gettype(BigInt(-123456))).toBe('bigint');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test('должна возвращать "float" для чисел с плавающей точкой', () => {
|
|
39
|
-
expect(gettype(3.14)).toBe('float');
|
|
40
|
-
expect(gettype(-0.99)).toBe('float');
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test('должна возвращать "string" для строк', () => {
|
|
44
|
-
expect(gettype('hello')).toBe('string');
|
|
45
|
-
expect(gettype('')).toBe('string');
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test('должна возвращать "symbol" для символов', () => {
|
|
49
|
-
expect(gettype(Symbol('symbol'))).toBe('symbol');
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
test('должна возвращать "class" для классов', () => {
|
|
53
|
-
class MyClass {}
|
|
54
|
-
expect(gettype(MyClass)).toBe('class');
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
test('должна возвращать "function" для функций', () => {
|
|
58
|
-
function func() {}
|
|
59
|
-
expect(gettype(func)).toBe('function');
|
|
60
|
-
expect(gettype(() => {})).toBe('function');
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
test('должна возвращать "array" для массивов', () => {
|
|
64
|
-
expect(gettype([])).toBe('array');
|
|
65
|
-
expect(gettype([1, 2, 3])).toBe('array');
|
|
66
|
-
expect(gettype({})).toBe('array');
|
|
67
|
-
expect(gettype({ foo: 'bar' })).toBe('array');
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
test('должна возвращать "object" для объектов', () => {
|
|
71
|
-
class MyClass {}
|
|
72
|
-
expect(gettype(new MyClass())).toBe('object');
|
|
73
|
-
});
|
|
74
|
-
});
|
|
1
|
+
import { expect, test } from '@jest/globals';
|
|
2
|
+
import { gettype } from '../../index.mjs';
|
|
3
|
+
|
|
4
|
+
describe('Функция gettype', () => {
|
|
5
|
+
test('должна возвращать "null" для null', () => {
|
|
6
|
+
expect(gettype(null)).toBe('null');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
test('должна возвращать "NaN" для NaN', () => {
|
|
10
|
+
expect(gettype(NaN)).toBe('NaN');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test('должна возвращать "undefined" для undefined', () => {
|
|
14
|
+
expect(gettype(undefined)).toBe('undefined');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('должна возвращать "infinity" для Infinity и -Infinity', () => {
|
|
18
|
+
expect(gettype(Infinity)).toBe('infinity');
|
|
19
|
+
expect(gettype(-Infinity)).toBe('infinity');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('должна возвращать "boolean" для логических значений', () => {
|
|
23
|
+
expect(gettype(true)).toBe('boolean');
|
|
24
|
+
expect(gettype(false)).toBe('boolean');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('должна возвращать "integer" для целых чисел', () => {
|
|
28
|
+
expect(gettype(42)).toBe('integer');
|
|
29
|
+
expect(gettype(-42)).toBe('integer');
|
|
30
|
+
expect(gettype(0)).toBe('integer');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('должна возвращать "bigint" для значений типа BigInt', () => {
|
|
34
|
+
expect(gettype(BigInt(123456))).toBe('bigint');
|
|
35
|
+
expect(gettype(BigInt(-123456))).toBe('bigint');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('должна возвращать "float" для чисел с плавающей точкой', () => {
|
|
39
|
+
expect(gettype(3.14)).toBe('float');
|
|
40
|
+
expect(gettype(-0.99)).toBe('float');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('должна возвращать "string" для строк', () => {
|
|
44
|
+
expect(gettype('hello')).toBe('string');
|
|
45
|
+
expect(gettype('')).toBe('string');
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('должна возвращать "symbol" для символов', () => {
|
|
49
|
+
expect(gettype(Symbol('symbol'))).toBe('symbol');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('должна возвращать "class" для классов', () => {
|
|
53
|
+
class MyClass {}
|
|
54
|
+
expect(gettype(MyClass)).toBe('class');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('должна возвращать "function" для функций', () => {
|
|
58
|
+
function func() {}
|
|
59
|
+
expect(gettype(func)).toBe('function');
|
|
60
|
+
expect(gettype(() => {})).toBe('function');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('должна возвращать "array" для массивов', () => {
|
|
64
|
+
expect(gettype([])).toBe('array');
|
|
65
|
+
expect(gettype([1, 2, 3])).toBe('array');
|
|
66
|
+
expect(gettype({})).toBe('array');
|
|
67
|
+
expect(gettype({ foo: 'bar' })).toBe('array');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('должна возвращать "object" для объектов', () => {
|
|
71
|
+
class MyClass {}
|
|
72
|
+
expect(gettype(new MyClass())).toBe('object');
|
|
73
|
+
});
|
|
74
|
+
});
|