@rogolev/value 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +319 -1
- package/docs/classes/Expect/toBe.md +61 -0
- package/docs/classes/Expect/toBeArray.md +52 -0
- package/docs/classes/Expect/toBeAssoc.md +53 -0
- package/docs/classes/Expect/toBeBigInt.md +52 -0
- package/docs/classes/Expect/toBeBool.md +53 -0
- package/docs/classes/Expect/toBeBoolean.md +53 -0
- package/docs/classes/Expect/toBeChar.md +53 -0
- package/docs/classes/Expect/toBeClass.md +53 -0
- package/docs/classes/Expect/toBeFloat.md +53 -0
- package/docs/classes/Expect/toBeFunction.md +52 -0
- package/docs/classes/Expect/toBeInfinity.md +53 -0
- package/docs/classes/Expect/toBeInt.md +53 -0
- package/docs/classes/Expect/toBeInteger.md +53 -0
- package/docs/classes/Expect/toBeList.md +53 -0
- package/docs/classes/Expect/toBeNaN.md +53 -0
- package/docs/classes/Expect/toBeNull.md +51 -0
- package/docs/classes/Expect/toBeNumber.md +52 -0
- package/docs/classes/Expect/toBeNumeric.md +53 -0
- package/docs/classes/Expect/toBeObject.md +52 -0
- package/docs/classes/Expect/toBeScalar.md +53 -0
- package/docs/classes/Expect/toBeString.md +52 -0
- package/docs/classes/Expect/toBeSymbol.md +53 -0
- package/docs/classes/Expect/toBeUndefined.md +54 -0
- package/docs/classes/Expect/toEqual.md +69 -0
- package/docs/classes/Expect/toStrictEqual.md +70 -0
- package/docs/classes/Expect.md +87 -0
- package/docs/classes/Type/expectArray.md +63 -0
- package/docs/classes/Type/expectAssoc.md +65 -0
- package/docs/classes/Type/expectBigInt.md +63 -0
- package/docs/classes/Type/expectBool.md +65 -0
- package/docs/classes/Type/expectBoolean.md +65 -0
- package/docs/classes/Type/expectChar.md +63 -0
- package/docs/classes/Type/expectClass.md +63 -0
- package/docs/classes/Type/expectFloat.md +68 -0
- package/docs/classes/Type/expectFunction.md +63 -0
- package/docs/classes/Type/expectInfinity.md +65 -0
- package/docs/classes/Type/expectInt.md +64 -0
- package/docs/classes/Type/expectInteger.md +64 -0
- package/docs/classes/Type/expectList.md +63 -0
- package/docs/classes/Type/expectNaN.md +63 -0
- package/docs/classes/Type/expectNull.md +63 -0
- package/docs/classes/Type/expectNumber.md +63 -0
- package/docs/classes/Type/expectNumeric.md +63 -0
- package/docs/classes/Type/expectObject.md +64 -0
- package/docs/classes/Type/expectScalar.md +63 -0
- package/docs/classes/Type/expectString.md +63 -0
- package/docs/classes/Type/expectSymbol.md +63 -0
- package/docs/classes/Type/expectUndefined.md +63 -0
- package/docs/classes/Type.md +101 -2
- package/docs/classes.md +2 -1
- package/docs/helpers/array/array_chunk.md +80 -0
- package/docs/helpers/array/array_chunk_with_keys.md +81 -0
- package/docs/helpers/array/array_column.md +110 -0
- package/docs/helpers/array/array_combine.md +77 -0
- package/docs/helpers/array/array_count_values.md +71 -0
- package/docs/helpers/array/array_diff.md +97 -0
- package/docs/helpers/array/array_diff_assoc.md +81 -0
- package/docs/helpers/array/array_diff_key.md +81 -0
- package/docs/helpers/array/array_diff_uassoc.md +101 -0
- package/docs/helpers/array/array_diff_ukey.md +101 -0
- package/docs/helpers/array/array_fill.md +81 -0
- package/docs/helpers/array/array_fill_keys.md +73 -0
- package/docs/helpers/array/array_filter.md +79 -0
- package/docs/helpers/array/array_flip.md +70 -0
- package/docs/helpers/array/array_index_max.md +78 -0
- package/docs/helpers/array/array_index_min.md +78 -0
- package/docs/helpers/array/array_intersect.md +91 -0
- package/docs/helpers/array/array_intersect_assoc.md +91 -0
- package/docs/helpers/array/array_intersect_key.md +91 -0
- package/docs/helpers/array/array_intersect_uassoc.md +101 -0
- package/docs/helpers/array/array_intersect_ukey.md +101 -0
- package/docs/helpers/array/array_key_exists.md +73 -0
- package/docs/helpers/array/array_key_first.md +62 -0
- package/docs/helpers/array/array_key_last.md +62 -0
- package/docs/helpers/array/array_key_to_lower_case.md +57 -0
- package/docs/helpers/array/array_key_to_upper_case.md +57 -0
- package/docs/helpers/array/array_keys.md +62 -0
- package/docs/helpers/array/array_map.md +69 -0
- package/docs/helpers/array/array_merge.md +67 -0
- package/docs/helpers/array/array_merge_recursive.md +86 -0
- package/docs/helpers/array/array_pad.md +83 -0
- package/docs/helpers/array/array_pop.md +64 -0
- package/docs/helpers/array/array_product.md +62 -0
- package/docs/helpers/array/array_push.md +57 -0
- package/docs/helpers/array/array_rand.md +99 -0
- package/docs/helpers/array/array_reduce.md +77 -0
- package/docs/helpers/array/array_replace.md +85 -0
- package/docs/helpers/array/array_replace_recursive.md +87 -0
- package/docs/helpers/array/array_reverse.md +55 -0
- package/docs/helpers/array/array_search.md +74 -0
- package/docs/helpers/array/array_shift.md +64 -0
- package/docs/helpers/array/array_slice.md +65 -0
- package/docs/helpers/array/array_splice.md +103 -0
- package/docs/helpers/array/array_sum.md +55 -0
- package/docs/helpers/array/array_udiff.md +97 -0
- package/docs/helpers/array/array_udiff_assoc.md +101 -0
- package/docs/helpers/array/array_udiff_uassoc.md +88 -0
- package/docs/helpers/array/array_uintersect.md +101 -0
- package/docs/helpers/array/array_uintersect_assoc.md +102 -0
- package/docs/helpers/array/array_uintersect_uassoc.md +135 -0
- package/docs/helpers/array/array_unique.md +54 -0
- package/docs/helpers/array/array_unshift.md +58 -0
- package/docs/helpers/array/array_values.md +54 -0
- package/docs/helpers/array/array_walk.md +87 -0
- package/docs/helpers/array/array_walk_recursive.md +93 -0
- package/docs/helpers/array/count.md +54 -0
- package/docs/helpers/array/in_array.md +65 -0
- package/docs/helpers/array/natsort.md +60 -0
- package/docs/helpers/array/range.md +76 -0
- package/docs/helpers/array/shuffle.md +74 -0
- package/docs/helpers/array/sort.md +79 -0
- package/docs/helpers/expect.md +58 -0
- package/docs/helpers/expect_array.md +63 -0
- package/docs/helpers/expect_assoc.md +65 -0
- package/docs/helpers/expect_bigint.md +63 -0
- package/docs/helpers/expect_bool.md +65 -0
- package/docs/helpers/expect_boolean.md +65 -0
- package/docs/helpers/expect_char.md +63 -0
- package/docs/helpers/expect_class.md +63 -0
- package/docs/helpers/expect_float.md +65 -0
- package/docs/helpers/expect_function.md +63 -0
- package/docs/helpers/expect_infinity.md +65 -0
- package/docs/helpers/expect_int.md +65 -0
- package/docs/helpers/expect_integer.md +65 -0
- package/docs/helpers/expect_list.md +63 -0
- package/docs/helpers/expect_nan.md +63 -0
- package/docs/helpers/expect_null.md +63 -0
- package/docs/helpers/expect_number.md +63 -0
- package/docs/helpers/expect_numeric.md +63 -0
- package/docs/helpers/expect_object.md +64 -0
- package/docs/helpers/expect_scalar.md +63 -0
- package/docs/helpers/expect_string.md +63 -0
- package/docs/helpers/expect_symbol.md +63 -0
- package/docs/helpers/expect_undefined.md +64 -0
- package/docs/helpers/is_char.md +84 -0
- package/docs/helpers/is_equal.md +75 -0
- package/docs/helpers/string/is_digit_char.md +70 -0
- package/docs/helpers/string/is_whitespace_char.md +70 -0
- package/docs/helpers/string/natcompare.md +69 -0
- package/docs/helpers/string/natcompare_numeric.md +70 -0
- package/docs/helpers.md +172 -1
- package/index.mjs +91 -1
- package/package.json +1 -1
- package/prettier.config.mjs +2 -1
- package/src/classes/Expect.mjs +1445 -0
- package/src/classes/Type.mjs +2739 -1284
- package/src/constants.mjs +83 -14
- package/src/helpers/array/array_chunk.mjs +102 -0
- package/src/helpers/array/array_chunk_with_keys.mjs +102 -0
- package/src/helpers/array/array_column.mjs +131 -0
- package/src/helpers/array/array_combine.mjs +26 -0
- package/src/helpers/array/array_count_values.mjs +82 -0
- package/src/helpers/array/array_diff.mjs +77 -0
- package/src/helpers/array/array_diff_assoc.mjs +56 -0
- package/src/helpers/array/array_diff_key.mjs +56 -0
- package/src/helpers/array/array_diff_uassoc.mjs +76 -0
- package/src/helpers/array/array_diff_ukey.mjs +71 -0
- package/src/helpers/array/array_fill.mjs +108 -0
- package/src/helpers/array/array_fill_keys.mjs +90 -0
- package/src/helpers/array/array_filter.mjs +105 -0
- package/src/helpers/array/array_flip.mjs +58 -0
- package/src/helpers/array/array_index_max.mjs +82 -0
- package/src/helpers/array/array_index_min.mjs +82 -0
- package/src/helpers/array/array_intersect.mjs +71 -0
- package/src/helpers/array/array_intersect_assoc.mjs +67 -0
- package/src/helpers/array/array_intersect_key.mjs +67 -0
- package/src/helpers/array/array_intersect_uassoc.mjs +77 -0
- package/src/helpers/array/array_intersect_ukey.mjs +72 -0
- package/src/helpers/array/array_key_exists.mjs +83 -0
- package/src/helpers/array/array_key_first.mjs +73 -0
- package/src/helpers/array/array_key_last.mjs +74 -0
- package/src/helpers/array/array_key_to_lower_case.mjs +71 -0
- package/src/helpers/array/array_key_to_upper_case.mjs +71 -0
- package/src/helpers/array/array_keys.mjs +65 -0
- package/src/helpers/array/array_map.mjs +84 -0
- package/src/helpers/array/array_merge.mjs +95 -0
- package/src/helpers/array/array_merge_recursive.mjs +153 -0
- package/src/helpers/array/array_pad.mjs +105 -0
- package/src/helpers/array/array_pop.mjs +82 -0
- package/src/helpers/array/array_product.mjs +67 -0
- package/src/helpers/array/array_push.mjs +75 -0
- package/src/helpers/array/array_rand.mjs +129 -0
- package/src/helpers/array/array_reduce.mjs +90 -0
- package/src/helpers/array/array_replace.mjs +25 -0
- package/src/helpers/array/array_replace_recursive.mjs +109 -0
- package/src/helpers/array/array_reverse.mjs +62 -0
- package/src/helpers/array/array_search.mjs +104 -0
- package/src/helpers/array/array_shift.mjs +78 -0
- package/src/helpers/array/array_slice.mjs +99 -0
- package/src/helpers/array/array_splice.mjs +218 -0
- package/src/helpers/array/array_sum.mjs +60 -0
- package/src/helpers/array/array_udiff.mjs +91 -0
- package/src/helpers/array/array_udiff_assoc.mjs +71 -0
- package/src/helpers/array/array_udiff_uassoc.mjs +124 -0
- package/src/helpers/array/array_uintersect.mjs +72 -0
- package/src/helpers/array/array_uintersect_assoc.mjs +77 -0
- package/src/helpers/array/array_uintersect_uassoc.mjs +121 -0
- package/src/helpers/array/array_unique.mjs +77 -0
- package/src/helpers/array/array_unshift.mjs +64 -0
- package/src/helpers/array/array_values.mjs +57 -0
- package/src/helpers/array/array_walk.mjs +95 -0
- package/src/helpers/array/array_walk_recursive.mjs +104 -0
- package/src/helpers/array/count.mjs +57 -0
- package/src/helpers/array/in_array.mjs +67 -0
- package/src/helpers/array/natsort.mjs +62 -0
- package/src/helpers/array/range.mjs +121 -0
- package/src/helpers/array/shuffle.mjs +73 -0
- package/src/helpers/array/sort.mjs +69 -0
- package/src/helpers/expect.mjs +44 -0
- package/src/helpers/expect_array.mjs +66 -0
- package/src/helpers/expect_assoc.mjs +66 -0
- package/src/helpers/expect_bigint.mjs +66 -0
- package/src/helpers/expect_bool.mjs +66 -0
- package/src/helpers/expect_boolean.mjs +57 -0
- package/src/helpers/expect_char.mjs +66 -0
- package/src/helpers/expect_class.mjs +66 -0
- package/src/helpers/expect_float.mjs +66 -0
- package/src/helpers/expect_function.mjs +66 -0
- package/src/helpers/expect_infinity.mjs +66 -0
- package/src/helpers/expect_int.mjs +66 -0
- package/src/helpers/expect_integer.mjs +57 -0
- package/src/helpers/expect_list.mjs +66 -0
- package/src/helpers/expect_nan.mjs +66 -0
- package/src/helpers/expect_null.mjs +66 -0
- package/src/helpers/expect_number.mjs +66 -0
- package/src/helpers/expect_numeric.mjs +66 -0
- package/src/helpers/expect_object.mjs +67 -0
- package/src/helpers/expect_scalar.mjs +66 -0
- package/src/helpers/expect_string.mjs +65 -0
- package/src/helpers/expect_symbol.mjs +66 -0
- package/src/helpers/expect_undefined.mjs +66 -0
- package/src/helpers/is_char.mjs +54 -0
- package/src/helpers/is_equal.mjs +94 -0
- package/src/helpers/string/is_digit_char.mjs +60 -0
- package/src/helpers/string/is_whitespace_char.mjs +54 -0
- package/src/helpers/string/natcompare.mjs +107 -0
- package/src/helpers/string/natcompare_numeric.mjs +131 -0
- package/tests/classes/Expect/toBe.test.mjs +60 -0
- package/tests/classes/Expect/toBeArray.test.mjs +46 -0
- package/tests/classes/Expect/toBeAssoc.test.mjs +48 -0
- package/tests/classes/Expect/toBeBigInt.test.mjs +46 -0
- package/tests/classes/Expect/toBeBool.test.mjs +48 -0
- package/tests/classes/Expect/toBeBoolean.test.mjs +48 -0
- package/tests/classes/Expect/toBeChar.test.mjs +46 -0
- package/tests/classes/Expect/toBeClass.test.mjs +48 -0
- package/tests/classes/Expect/toBeFloat.test.mjs +48 -0
- package/tests/classes/Expect/toBeFunction.test.mjs +51 -0
- package/tests/classes/Expect/toBeInfinity.test.mjs +48 -0
- package/tests/classes/Expect/toBeInt.test.mjs +48 -0
- package/tests/classes/Expect/toBeInteger.test.mjs +48 -0
- package/tests/classes/Expect/toBeList.test.mjs +46 -0
- package/tests/classes/Expect/toBeNaN.test.mjs +46 -0
- package/tests/classes/Expect/toBeNull.test.mjs +46 -0
- package/tests/classes/Expect/toBeNumber.test.mjs +46 -0
- package/tests/classes/Expect/toBeNumeric.test.mjs +53 -0
- package/tests/classes/Expect/toBeObject.test.mjs +47 -0
- package/tests/classes/Expect/toBeScalar.test.mjs +63 -0
- package/tests/classes/Expect/toBeString.test.mjs +46 -0
- package/tests/classes/Expect/toBeSymbol.test.mjs +46 -0
- package/tests/classes/Expect/toBeUndefined.test.mjs +50 -0
- package/tests/classes/Expect/toEqual.test.mjs +66 -0
- package/tests/classes/Expect/toStrictEqual.test.mjs +73 -0
- package/tests/classes/Type.test.mjs +1320 -1262
- package/tests/helpers/array/array_chunk.test.mjs +49 -0
- package/tests/helpers/array/array_chunk_with_keys.test.mjs +45 -0
- package/tests/helpers/array/array_column.test.mjs +87 -0
- package/tests/helpers/array/array_combine.test.mjs +41 -0
- package/tests/helpers/array/array_count_values.test.mjs +40 -0
- package/tests/helpers/array/array_diff.test.mjs +78 -0
- package/tests/helpers/array/array_diff_assoc.test.mjs +64 -0
- package/tests/helpers/array/array_diff_key.test.mjs +64 -0
- package/tests/helpers/array/array_diff_uassoc.test.mjs +73 -0
- package/tests/helpers/array/array_diff_ukey.test.mjs +77 -0
- package/tests/helpers/array/array_fill.test.mjs +47 -0
- package/tests/helpers/array/array_fill_keys.test.mjs +35 -0
- package/tests/helpers/array/array_filter.test.mjs +38 -0
- package/tests/helpers/array/array_flip.test.mjs +33 -0
- package/tests/helpers/array/array_index_max.test.mjs +41 -0
- package/tests/helpers/array/array_index_min.test.mjs +41 -0
- package/tests/helpers/array/array_intersect.test.mjs +65 -0
- package/tests/helpers/array/array_intersect_assoc.test.mjs +65 -0
- package/tests/helpers/array/array_intersect_key.test.mjs +65 -0
- package/tests/helpers/array/array_intersect_uassoc.test.mjs +76 -0
- package/tests/helpers/array/array_intersect_ukey.test.mjs +74 -0
- package/tests/helpers/array/array_key_exists.test.mjs +36 -0
- package/tests/helpers/array/array_key_first.test.mjs +29 -0
- package/tests/helpers/array/array_key_last.test.mjs +29 -0
- package/tests/helpers/array/array_key_to_lower_case.test.mjs +23 -0
- package/tests/helpers/array/array_key_to_upper_case.test.mjs +23 -0
- package/tests/helpers/array/array_keys.test.mjs +27 -0
- package/tests/helpers/array/array_map.test.mjs +32 -0
- package/tests/helpers/array/array_merge.test.mjs +37 -0
- package/tests/helpers/array/array_merge_recursive.test.mjs +65 -0
- package/tests/helpers/array/array_pad.test.mjs +48 -0
- package/tests/helpers/array/array_pop.test.mjs +29 -0
- package/tests/helpers/array/array_product.test.mjs +33 -0
- package/tests/helpers/array/array_push.test.mjs +31 -0
- package/tests/helpers/array/array_rand.test.mjs +59 -0
- package/tests/helpers/array/array_reduce.test.mjs +44 -0
- package/tests/helpers/array/array_replace.test.mjs +46 -0
- package/tests/helpers/array/array_replace_recursive.test.mjs +46 -0
- package/tests/helpers/array/array_reverse.test.mjs +31 -0
- package/tests/helpers/array/array_search.test.mjs +48 -0
- package/tests/helpers/array/array_shift.test.mjs +29 -0
- package/tests/helpers/array/array_slice.test.mjs +49 -0
- package/tests/helpers/array/array_splice.test.mjs +67 -0
- package/tests/helpers/array/array_sum.test.mjs +27 -0
- package/tests/helpers/array/array_udiff.test.mjs +95 -0
- package/tests/helpers/array/array_udiff_assoc.test.mjs +77 -0
- package/tests/helpers/array/array_udiff_uassoc.test.mjs +89 -0
- package/tests/helpers/array/array_uintersect.test.mjs +78 -0
- package/tests/helpers/array/array_uintersect_assoc.test.mjs +80 -0
- package/tests/helpers/array/array_uintersect_uassoc.test.mjs +122 -0
- package/tests/helpers/array/array_unique.test.mjs +27 -0
- package/tests/helpers/array/array_unshift.test.mjs +31 -0
- package/tests/helpers/array/array_values.test.mjs +27 -0
- package/tests/helpers/array/array_walk.test.mjs +48 -0
- package/tests/helpers/array/array_walk_recursive.test.mjs +53 -0
- package/tests/helpers/array/count.test.mjs +27 -0
- package/tests/helpers/array/in_array.test.mjs +52 -0
- package/tests/helpers/array/natsort.test.mjs +71 -0
- package/tests/helpers/array/range.test.mjs +51 -0
- package/tests/helpers/array/shuffle.test.mjs +42 -0
- package/tests/helpers/array/sort.test.mjs +60 -0
- package/tests/helpers/array.test.mjs +58 -58
- package/tests/helpers/expect.test.mjs +95 -0
- package/tests/helpers/expect_array.test.mjs +71 -0
- package/tests/helpers/expect_assoc.test.mjs +61 -0
- package/tests/helpers/expect_bigint.test.mjs +63 -0
- package/tests/helpers/expect_bool.test.mjs +59 -0
- package/tests/helpers/expect_boolean.test.mjs +61 -0
- package/tests/helpers/expect_char.test.mjs +63 -0
- package/tests/helpers/expect_class.test.mjs +64 -0
- package/tests/helpers/expect_float.test.mjs +64 -0
- package/tests/helpers/expect_function.test.mjs +65 -0
- package/tests/helpers/expect_infinity.test.mjs +62 -0
- package/tests/helpers/expect_int.test.mjs +57 -0
- package/tests/helpers/expect_integer.test.mjs +59 -0
- package/tests/helpers/expect_list.test.mjs +73 -0
- package/tests/helpers/expect_nan.test.mjs +57 -0
- package/tests/helpers/expect_null.test.mjs +57 -0
- package/tests/helpers/expect_number.test.mjs +57 -0
- package/tests/helpers/expect_numeric.test.mjs +57 -0
- package/tests/helpers/expect_object.test.mjs +63 -0
- package/tests/helpers/expect_scalar.test.mjs +72 -0
- package/tests/helpers/expect_string.test.mjs +65 -0
- package/tests/helpers/expect_symbol.test.mjs +66 -0
- package/tests/helpers/expect_undefined.test.mjs +59 -0
- package/tests/helpers/is_char.test.mjs +40 -0
- package/tests/helpers/is_equal.test.mjs +110 -0
- package/tests/helpers/string/is_digit_char.test.mjs +32 -0
- package/tests/helpers/string/is_whitespace_char.test.mjs +32 -0
- package/tests/helpers/string/natcompare.test.mjs +100 -0
- package/tests/helpers/string/natcompare_numeric.test.mjs +110 -0
@@ -0,0 +1,63 @@
|
|
1
|
+
import { expect, test, describe } from '@jest/globals';
|
2
|
+
import { expect_object } from '../../index.mjs';
|
3
|
+
|
4
|
+
describe('Функция expect_object', () => {
|
5
|
+
test('Должна возвращать true, если значение является объектом', () => {
|
6
|
+
class stdClass {}
|
7
|
+
const value = new stdClass();
|
8
|
+
|
9
|
+
expect(expect_object(value)).toBe(true);
|
10
|
+
});
|
11
|
+
|
12
|
+
test('Должна корректно обрабатывать ассоциативные массивы', () => {
|
13
|
+
expect(() => expect_object({ a: 1, b: 2 })).toThrow(TypeError);
|
14
|
+
expect(() => expect_object({ a: 1, b: 2 })).toThrow('');
|
15
|
+
});
|
16
|
+
|
17
|
+
test('Должна выбрасывать ошибку, если значение не является объектом', () => {
|
18
|
+
expect(() => expect_object(123)).toThrow(TypeError);
|
19
|
+
expect(() => expect_object(123)).toThrow('');
|
20
|
+
});
|
21
|
+
|
22
|
+
test('Должна выбрасывать ошибку с пользовательским сообщением, если значение не является объектом', () => {
|
23
|
+
expect(() => expect_object(123, 'Значение должно быть объектом.')).toThrow(TypeError);
|
24
|
+
expect(() => expect_object(123, 'Значение должно быть объектом.')).toThrow(
|
25
|
+
'Значение должно быть объектом.',
|
26
|
+
);
|
27
|
+
});
|
28
|
+
|
29
|
+
test('Должна выбрасывать ошибку, если параметр message не является строкой', () => {
|
30
|
+
expect(() => expect_object({}, 123)).toThrow(TypeError);
|
31
|
+
expect(() => expect_object({}, 123)).toThrow('Параметр "message" должен быть строкой.');
|
32
|
+
});
|
33
|
+
|
34
|
+
test('Должна корректно обрабатывать значение null', () => {
|
35
|
+
expect(() => expect_object(null)).toThrow(TypeError);
|
36
|
+
expect(() => expect_object(null)).toThrow('');
|
37
|
+
});
|
38
|
+
|
39
|
+
test('Должна корректно обрабатывать значение undefined', () => {
|
40
|
+
expect(() => expect_object(undefined)).toThrow(TypeError);
|
41
|
+
expect(() => expect_object(undefined)).toThrow('');
|
42
|
+
});
|
43
|
+
|
44
|
+
test('Должна корректно обрабатывать значение строки', () => {
|
45
|
+
expect(() => expect_object('object')).toThrow(TypeError);
|
46
|
+
expect(() => expect_object('object')).toThrow('');
|
47
|
+
});
|
48
|
+
|
49
|
+
test('Должна корректно обрабатывать значение числа', () => {
|
50
|
+
expect(() => expect_object(123)).toThrow(TypeError);
|
51
|
+
expect(() => expect_object(123)).toThrow('');
|
52
|
+
});
|
53
|
+
|
54
|
+
test('Должна корректно обрабатывать значение NaN', () => {
|
55
|
+
expect(() => expect_object(NaN)).toThrow(TypeError);
|
56
|
+
expect(() => expect_object(NaN)).toThrow('');
|
57
|
+
});
|
58
|
+
|
59
|
+
test('Должна корректно обрабатывать значение массива', () => {
|
60
|
+
expect(() => expect_object([1, 2, 3])).toThrow(TypeError);
|
61
|
+
expect(() => expect_object([1, 2, 3])).toThrow('');
|
62
|
+
});
|
63
|
+
});
|
@@ -0,0 +1,72 @@
|
|
1
|
+
import { expect, test, describe } from '@jest/globals';
|
2
|
+
import { expect_scalar } from '../../index.mjs';
|
3
|
+
|
4
|
+
describe('Функция expect_scalar', () => {
|
5
|
+
test('Должна возвращать true, если значение является скалярным', () => {
|
6
|
+
const value = 123;
|
7
|
+
const result = expect_scalar(value);
|
8
|
+
expect(result).toBe(true);
|
9
|
+
});
|
10
|
+
|
11
|
+
test('Должна выбрасывать ошибку, если значение не является скалярным', () => {
|
12
|
+
expect(() => expect_scalar([1, 2, 3])).toThrow(TypeError);
|
13
|
+
expect(() => expect_scalar([1, 2, 3])).toThrow('');
|
14
|
+
});
|
15
|
+
|
16
|
+
test('Должна выбрасывать ошибку с пользовательским сообщением, если значение не является скалярным', () => {
|
17
|
+
expect(() => expect_scalar([1, 2, 3], 'Значение должно быть скалярным.')).toThrow(
|
18
|
+
TypeError,
|
19
|
+
);
|
20
|
+
expect(() => expect_scalar([1, 2, 3], 'Значение должно быть скалярным.')).toThrow(
|
21
|
+
'Значение должно быть скалярным.',
|
22
|
+
);
|
23
|
+
});
|
24
|
+
|
25
|
+
test('Должна выбрасывать ошибку, если параметр message не является строкой', () => {
|
26
|
+
expect(() => expect_scalar(123, 123)).toThrow(TypeError);
|
27
|
+
expect(() => expect_scalar(123, 123)).toThrow('Параметр "message" должен быть строкой.');
|
28
|
+
});
|
29
|
+
|
30
|
+
test('Должна корректно обрабатывать значение null', () => {
|
31
|
+
expect(() => expect_scalar(null)).toThrow(TypeError);
|
32
|
+
expect(() => expect_scalar(null)).toThrow('');
|
33
|
+
});
|
34
|
+
|
35
|
+
test('Должна корректно обрабатывать значение undefined', () => {
|
36
|
+
expect(() => expect_scalar(undefined)).toThrow(TypeError);
|
37
|
+
expect(() => expect_scalar(undefined)).toThrow('');
|
38
|
+
});
|
39
|
+
|
40
|
+
test('Должна корректно обрабатывать значение объекта', () => {
|
41
|
+
expect(() => expect_scalar({})).toThrow(TypeError);
|
42
|
+
expect(() => expect_scalar({})).toThrow('');
|
43
|
+
});
|
44
|
+
|
45
|
+
test('Должна корректно обрабатывать значение строки', () => {
|
46
|
+
const value = 'scalar';
|
47
|
+
const result = expect_scalar(value);
|
48
|
+
expect(result).toBe(true);
|
49
|
+
});
|
50
|
+
|
51
|
+
test('Должна корректно обрабатывать значение числа', () => {
|
52
|
+
const value = 123;
|
53
|
+
const result = expect_scalar(value);
|
54
|
+
expect(result).toBe(true);
|
55
|
+
});
|
56
|
+
|
57
|
+
test('Должна корректно обрабатывать значение NaN', () => {
|
58
|
+
expect(() => expect_scalar(NaN)).toThrow(TypeError);
|
59
|
+
expect(() => expect_scalar(NaN)).toThrow('');
|
60
|
+
});
|
61
|
+
|
62
|
+
test('Должна корректно обрабатывать значение Infinity', () => {
|
63
|
+
expect(() => expect_scalar(Infinity)).toThrow(TypeError);
|
64
|
+
expect(() => expect_scalar(Infinity)).toThrow('');
|
65
|
+
});
|
66
|
+
|
67
|
+
test('Должна корректно обрабатывать значение boolean', () => {
|
68
|
+
const value = true;
|
69
|
+
const result = expect_scalar(value);
|
70
|
+
expect(result).toBe(true);
|
71
|
+
});
|
72
|
+
});
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import { expect, test, describe } from '@jest/globals';
|
2
|
+
import { expect_string } from '../../index.mjs';
|
3
|
+
|
4
|
+
describe('Функция expect_string', () => {
|
5
|
+
test('Должна возвращать true, если значение является строкой', () => {
|
6
|
+
const value = 'Hello, world!';
|
7
|
+
const result = expect_string(value);
|
8
|
+
expect(result).toBe(true);
|
9
|
+
});
|
10
|
+
|
11
|
+
test('Должна выбрасывать ошибку, если значение не является строкой', () => {
|
12
|
+
expect(() => expect_string(123)).toThrow(TypeError);
|
13
|
+
expect(() => expect_string(123)).toThrow('');
|
14
|
+
});
|
15
|
+
|
16
|
+
test('Должна выбрасывать ошибку с пользовательским сообщением, если значение не является строкой', () => {
|
17
|
+
expect(() => expect_string(123, 'Значение должно быть строкой.')).toThrow(TypeError);
|
18
|
+
expect(() => expect_string(123, 'Значение должно быть строкой.')).toThrow(
|
19
|
+
'Значение должно быть строкой.',
|
20
|
+
);
|
21
|
+
});
|
22
|
+
|
23
|
+
test('Должна выбрасывать ошибку, если параметр message не является строкой', () => {
|
24
|
+
expect(() => expect_string('Hello, world!', 123)).toThrow(TypeError);
|
25
|
+
expect(() => expect_string('Hello, world!', 123)).toThrow(
|
26
|
+
'Параметр "message" должен быть строкой.',
|
27
|
+
);
|
28
|
+
});
|
29
|
+
|
30
|
+
test('Должна корректно обрабатывать значение null', () => {
|
31
|
+
expect(() => expect_string(null)).toThrow(TypeError);
|
32
|
+
expect(() => expect_string(null)).toThrow('');
|
33
|
+
});
|
34
|
+
|
35
|
+
test('Должна корректно обрабатывать значение undefined', () => {
|
36
|
+
expect(() => expect_string(undefined)).toThrow(TypeError);
|
37
|
+
expect(() => expect_string(undefined)).toThrow('');
|
38
|
+
});
|
39
|
+
|
40
|
+
test('Должна корректно обрабатывать значение объекта', () => {
|
41
|
+
expect(() => expect_string({})).toThrow(TypeError);
|
42
|
+
expect(() => expect_string({})).toThrow('');
|
43
|
+
});
|
44
|
+
|
45
|
+
test('Должна корректно обрабатывать значение числа', () => {
|
46
|
+
expect(() => expect_string(123)).toThrow(TypeError);
|
47
|
+
expect(() => expect_string(123)).toThrow('');
|
48
|
+
});
|
49
|
+
|
50
|
+
test('Должна корректно обрабатывать значение NaN', () => {
|
51
|
+
expect(() => expect_string(NaN)).toThrow(TypeError);
|
52
|
+
expect(() => expect_string(NaN)).toThrow('');
|
53
|
+
});
|
54
|
+
|
55
|
+
test('Должна корректно обрабатывать значение Infinity', () => {
|
56
|
+
expect(() => expect_string(Infinity)).toThrow(TypeError);
|
57
|
+
expect(() => expect_string(Infinity)).toThrow('');
|
58
|
+
});
|
59
|
+
|
60
|
+
test('Должна корректно обрабатывать значение пустой строки', () => {
|
61
|
+
const value = '';
|
62
|
+
const result = expect_string(value);
|
63
|
+
expect(result).toBe(true);
|
64
|
+
});
|
65
|
+
});
|
@@ -0,0 +1,66 @@
|
|
1
|
+
import { expect, test, describe } from '@jest/globals';
|
2
|
+
import { expect_symbol } from '../../index.mjs';
|
3
|
+
|
4
|
+
describe('Функция expect_symbol', () => {
|
5
|
+
test('Должна возвращать true, если значение является символом', () => {
|
6
|
+
const value = Symbol('example');
|
7
|
+
const result = expect_symbol(value);
|
8
|
+
expect(result).toBe(true);
|
9
|
+
});
|
10
|
+
|
11
|
+
test('Должна выбрасывать ошибку, если значение не является символом', () => {
|
12
|
+
expect(() => expect_symbol('not a symbol')).toThrow(TypeError);
|
13
|
+
expect(() => expect_symbol('not a symbol')).toThrow('');
|
14
|
+
});
|
15
|
+
|
16
|
+
test('Должна выбрасывать ошибку с пользовательским сообщением, если значение не является символом', () => {
|
17
|
+
expect(() => expect_symbol('not a symbol', 'Значение должно быть символом.')).toThrow(
|
18
|
+
TypeError,
|
19
|
+
);
|
20
|
+
expect(() => expect_symbol('not a symbol', 'Значение должно быть символом.')).toThrow(
|
21
|
+
'Значение должно быть символом.',
|
22
|
+
);
|
23
|
+
});
|
24
|
+
|
25
|
+
test('Должна выбрасывать ошибку, если параметр message не является строкой', () => {
|
26
|
+
expect(() => expect_symbol(Symbol('example'), 123)).toThrow(TypeError);
|
27
|
+
expect(() => expect_symbol(Symbol('example'), 123)).toThrow(
|
28
|
+
'Параметр "message" должен быть строкой.',
|
29
|
+
);
|
30
|
+
});
|
31
|
+
|
32
|
+
test('Должна корректно обрабатывать значение null', () => {
|
33
|
+
expect(() => expect_symbol(null)).toThrow(TypeError);
|
34
|
+
expect(() => expect_symbol(null)).toThrow('');
|
35
|
+
});
|
36
|
+
|
37
|
+
test('Должна корректно обрабатывать значение undefined', () => {
|
38
|
+
expect(() => expect_symbol(undefined)).toThrow(TypeError);
|
39
|
+
expect(() => expect_symbol(undefined)).toThrow('');
|
40
|
+
});
|
41
|
+
|
42
|
+
test('Должна корректно обрабатывать значение объекта', () => {
|
43
|
+
expect(() => expect_symbol({})).toThrow(TypeError);
|
44
|
+
expect(() => expect_symbol({})).toThrow('');
|
45
|
+
});
|
46
|
+
|
47
|
+
test('Должна корректно обрабатывать значение строки', () => {
|
48
|
+
expect(() => expect_symbol('symbol')).toThrow(TypeError);
|
49
|
+
expect(() => expect_symbol('symbol')).toThrow('');
|
50
|
+
});
|
51
|
+
|
52
|
+
test('Должна корректно обрабатывать значение числа', () => {
|
53
|
+
expect(() => expect_symbol(123)).toThrow(TypeError);
|
54
|
+
expect(() => expect_symbol(123)).toThrow('');
|
55
|
+
});
|
56
|
+
|
57
|
+
test('Должна корректно обрабатывать значение NaN', () => {
|
58
|
+
expect(() => expect_symbol(NaN)).toThrow(TypeError);
|
59
|
+
expect(() => expect_symbol(NaN)).toThrow('');
|
60
|
+
});
|
61
|
+
|
62
|
+
test('Должна корректно обрабатывать значение Infinity', () => {
|
63
|
+
expect(() => expect_symbol(Infinity)).toThrow(TypeError);
|
64
|
+
expect(() => expect_symbol(Infinity)).toThrow('');
|
65
|
+
});
|
66
|
+
});
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import { expect, test, describe } from '@jest/globals';
|
2
|
+
import { expect_undefined } from '../../index.mjs';
|
3
|
+
|
4
|
+
describe('Функция expect_undefined', () => {
|
5
|
+
test('Должна возвращать true, если значение является undefined', () => {
|
6
|
+
let value;
|
7
|
+
const result = expect_undefined(value);
|
8
|
+
expect(result).toBe(true);
|
9
|
+
});
|
10
|
+
|
11
|
+
test('Должна выбрасывать ошибку, если значение не является undefined', () => {
|
12
|
+
expect(() => expect_undefined(123)).toThrow(TypeError);
|
13
|
+
expect(() => expect_undefined(123)).toThrow('');
|
14
|
+
});
|
15
|
+
|
16
|
+
test('Должна выбрасывать ошибку с пользовательским сообщением, если значение не является undefined', () => {
|
17
|
+
expect(() => expect_undefined(123, 'Значение должно быть undefined.')).toThrow(TypeError);
|
18
|
+
expect(() => expect_undefined(123, 'Значение должно быть undefined.')).toThrow(
|
19
|
+
'Значение должно быть undefined.',
|
20
|
+
);
|
21
|
+
});
|
22
|
+
|
23
|
+
test('Должна выбрасывать ошибку, если параметр message не является строкой', () => {
|
24
|
+
expect(() => expect_undefined(undefined, 123)).toThrow(TypeError);
|
25
|
+
expect(() => expect_undefined(undefined, 123)).toThrow(
|
26
|
+
'Параметр "message" должен быть строкой.',
|
27
|
+
);
|
28
|
+
});
|
29
|
+
|
30
|
+
test('Должна корректно обрабатывать значение null', () => {
|
31
|
+
expect(() => expect_undefined(null)).toThrow(TypeError);
|
32
|
+
expect(() => expect_undefined(null)).toThrow('');
|
33
|
+
});
|
34
|
+
|
35
|
+
test('Должна корректно обрабатывать значение объекта', () => {
|
36
|
+
expect(() => expect_undefined({})).toThrow(TypeError);
|
37
|
+
expect(() => expect_undefined({})).toThrow('');
|
38
|
+
});
|
39
|
+
|
40
|
+
test('Должна корректно обрабатывать значение строки', () => {
|
41
|
+
expect(() => expect_undefined('undefined')).toThrow(TypeError);
|
42
|
+
expect(() => expect_undefined('undefined')).toThrow('');
|
43
|
+
});
|
44
|
+
|
45
|
+
test('Должна корректно обрабатывать значение числа', () => {
|
46
|
+
expect(() => expect_undefined(123)).toThrow(TypeError);
|
47
|
+
expect(() => expect_undefined(123)).toThrow('');
|
48
|
+
});
|
49
|
+
|
50
|
+
test('Должна корректно обрабатывать значение NaN', () => {
|
51
|
+
expect(() => expect_undefined(NaN)).toThrow(TypeError);
|
52
|
+
expect(() => expect_undefined(NaN)).toThrow('');
|
53
|
+
});
|
54
|
+
|
55
|
+
test('Должна корректно обрабатывать значение Infinity', () => {
|
56
|
+
expect(() => expect_undefined(Infinity)).toThrow(TypeError);
|
57
|
+
expect(() => expect_undefined(Infinity)).toThrow('');
|
58
|
+
});
|
59
|
+
});
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import { expect, test, describe } from '@jest/globals';
|
2
|
+
import { is_char } from '../../index.mjs';
|
3
|
+
|
4
|
+
describe('Функция is_char', () => {
|
5
|
+
test('Должна возвращать true для одиночного символа', () => {
|
6
|
+
expect(is_char('a')).toBe(true);
|
7
|
+
});
|
8
|
+
|
9
|
+
test('Должна возвращать false для строки из нескольких символов', () => {
|
10
|
+
expect(is_char('abc')).toBe(false);
|
11
|
+
});
|
12
|
+
|
13
|
+
test('Должна возвращать false для пустой строки', () => {
|
14
|
+
expect(is_char('')).toBe(false);
|
15
|
+
});
|
16
|
+
|
17
|
+
test('Должна возвращать false для значения, не являющегося строкой', () => {
|
18
|
+
expect(is_char(1)).toBe(false);
|
19
|
+
expect(is_char(null)).toBe(false);
|
20
|
+
expect(is_char(undefined)).toBe(false);
|
21
|
+
expect(is_char({})).toBe(false);
|
22
|
+
expect(is_char([])).toBe(false);
|
23
|
+
});
|
24
|
+
|
25
|
+
test('Должна возвращать true для пробельного символа', () => {
|
26
|
+
expect(is_char(' ')).toBe(true);
|
27
|
+
});
|
28
|
+
|
29
|
+
test('Должна возвращать false для строки с пробелами', () => {
|
30
|
+
expect(is_char(' a ')).toBe(false);
|
31
|
+
});
|
32
|
+
|
33
|
+
test('Должна возвращать false для строки с числовыми значениями', () => {
|
34
|
+
expect(is_char('123')).toBe(false);
|
35
|
+
});
|
36
|
+
|
37
|
+
test('Должна возвращать true для одиночного числового символа', () => {
|
38
|
+
expect(is_char('1')).toBe(true);
|
39
|
+
});
|
40
|
+
});
|
@@ -0,0 +1,110 @@
|
|
1
|
+
import { expect, test, describe } from '@jest/globals';
|
2
|
+
import { is_equal } from '../../index.mjs';
|
3
|
+
|
4
|
+
describe('Функция is_equal', () => {
|
5
|
+
test('Должна возвращать true для одинаковых чисел', () => {
|
6
|
+
expect(is_equal(1, 1)).toBe(true);
|
7
|
+
});
|
8
|
+
|
9
|
+
test('Должна возвращать false для разных чисел', () => {
|
10
|
+
expect(is_equal(1, 2)).toBe(false);
|
11
|
+
});
|
12
|
+
|
13
|
+
test('Должна возвращать true для одинаковых строк', () => {
|
14
|
+
expect(is_equal('hello', 'hello')).toBe(true);
|
15
|
+
});
|
16
|
+
|
17
|
+
test('Должна возвращать false для разных строк', () => {
|
18
|
+
expect(is_equal('hello', 'world')).toBe(false);
|
19
|
+
});
|
20
|
+
|
21
|
+
test('Должна возвращать true для одинаковых объектов', () => {
|
22
|
+
const obj1 = { a: 1, b: 2 };
|
23
|
+
const obj2 = { a: 1, b: 2 };
|
24
|
+
expect(is_equal(obj1, obj2)).toBe(true);
|
25
|
+
});
|
26
|
+
|
27
|
+
test('Должна возвращать false для объектов с разными значениями', () => {
|
28
|
+
const obj1 = { a: 1, b: 2 };
|
29
|
+
const obj2 = { a: 1, b: 3 };
|
30
|
+
expect(is_equal(obj1, obj2)).toBe(false);
|
31
|
+
});
|
32
|
+
|
33
|
+
test('Должна возвращать false для объектов с разными ключами', () => {
|
34
|
+
const obj1 = { a: 1, b: 2 };
|
35
|
+
const obj2 = { a: 1, c: 2 };
|
36
|
+
expect(is_equal(obj1, obj2)).toBe(false);
|
37
|
+
});
|
38
|
+
|
39
|
+
test('Должна возвращать true для одинаковых массивов', () => {
|
40
|
+
const arr1 = [1, 2, 3];
|
41
|
+
const arr2 = [1, 2, 3];
|
42
|
+
expect(is_equal(arr1, arr2)).toBe(true);
|
43
|
+
});
|
44
|
+
|
45
|
+
test('Должна возвращать false для массивов с разными значениями', () => {
|
46
|
+
const arr1 = [1, 2, 3];
|
47
|
+
const arr2 = [1, 2, 4];
|
48
|
+
expect(is_equal(arr1, arr2)).toBe(false);
|
49
|
+
});
|
50
|
+
|
51
|
+
test('Должна возвращать true для вложенных объектов с одинаковыми значениями', () => {
|
52
|
+
const obj1 = { a: { b: 2 } };
|
53
|
+
const obj2 = { a: { b: 2 } };
|
54
|
+
expect(is_equal(obj1, obj2)).toBe(true);
|
55
|
+
});
|
56
|
+
|
57
|
+
test('Должна возвращать false для вложенных объектов с разными значениями', () => {
|
58
|
+
const obj1 = { a: { b: 2 } };
|
59
|
+
const obj2 = { a: { b: 3 } };
|
60
|
+
expect(is_equal(obj1, obj2)).toBe(false);
|
61
|
+
});
|
62
|
+
|
63
|
+
test('Должна возвращать true для одинаковых символов', () => {
|
64
|
+
const sym1 = Symbol('test');
|
65
|
+
const sym2 = sym1;
|
66
|
+
expect(is_equal(sym1, sym2)).toBe(true);
|
67
|
+
});
|
68
|
+
|
69
|
+
test('Должна возвращать false для разных символов', () => {
|
70
|
+
const sym1 = Symbol('test');
|
71
|
+
const sym2 = Symbol('test');
|
72
|
+
expect(is_equal(sym1, sym2)).toBe(false);
|
73
|
+
});
|
74
|
+
|
75
|
+
test('Должна возвращать true для одинаковых значений null', () => {
|
76
|
+
expect(is_equal(null, null)).toBe(true);
|
77
|
+
});
|
78
|
+
|
79
|
+
test('Должна возвращать true для null и undefined', () => {
|
80
|
+
expect(is_equal(null, undefined)).toBe(true);
|
81
|
+
});
|
82
|
+
|
83
|
+
test('Должна возвращать true для одинаковых значений undefined', () => {
|
84
|
+
expect(is_equal(undefined, undefined)).toBe(true);
|
85
|
+
});
|
86
|
+
|
87
|
+
test('Должна возвращать false для одинаковых значений NaN', () => {
|
88
|
+
expect(is_equal(NaN, NaN)).toBe(false);
|
89
|
+
});
|
90
|
+
|
91
|
+
test('Должна возвращать false для NaN и числа', () => {
|
92
|
+
expect(is_equal(NaN, 1)).toBe(false);
|
93
|
+
});
|
94
|
+
|
95
|
+
test('Должна возвращать true для одинаковых чисел в строгом режиме', () => {
|
96
|
+
expect(is_equal(1, 1, true)).toBe(true);
|
97
|
+
});
|
98
|
+
|
99
|
+
test('Должна возвращать false для чисел и строк в строгом режиме', () => {
|
100
|
+
expect(is_equal(1, '1', true)).toBe(false);
|
101
|
+
});
|
102
|
+
|
103
|
+
test('Должна возвращать true для одинаковых строк в строгом режиме', () => {
|
104
|
+
expect(is_equal('hello', 'hello', true)).toBe(true);
|
105
|
+
});
|
106
|
+
|
107
|
+
test('Должна возвращать false для строк и чисел в строгом режиме', () => {
|
108
|
+
expect(is_equal('1', 1, true)).toBe(false);
|
109
|
+
});
|
110
|
+
});
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { expect, test, describe } from '@jest/globals';
|
2
|
+
import { is_digit_char } from '../../../index.mjs';
|
3
|
+
|
4
|
+
describe('Функция is_digit_char', () => {
|
5
|
+
test('Должна возвращать true для цифрового символа', () => {
|
6
|
+
expect(is_digit_char('0')).toBe(true);
|
7
|
+
expect(is_digit_char('5')).toBe(true);
|
8
|
+
expect(is_digit_char('9')).toBe(true);
|
9
|
+
});
|
10
|
+
|
11
|
+
test('Должна возвращать false для непробельного символа', () => {
|
12
|
+
expect(is_digit_char('a')).toBe(false);
|
13
|
+
expect(is_digit_char(' ')).toBe(false);
|
14
|
+
expect(is_digit_char('!')).toBe(false);
|
15
|
+
});
|
16
|
+
|
17
|
+
test('Должна возвращать false для строки из нескольких символов', () => {
|
18
|
+
expect(is_digit_char('123')).toBe(false);
|
19
|
+
});
|
20
|
+
|
21
|
+
test('Должна возвращать false для пустой строки', () => {
|
22
|
+
expect(is_digit_char('')).toBe(false);
|
23
|
+
});
|
24
|
+
|
25
|
+
test('Должна возвращать false для значения, не являющегося строкой', () => {
|
26
|
+
expect(is_digit_char(1)).toBe(false);
|
27
|
+
expect(is_digit_char(null)).toBe(false);
|
28
|
+
expect(is_digit_char(undefined)).toBe(false);
|
29
|
+
expect(is_digit_char({})).toBe(false);
|
30
|
+
expect(is_digit_char([])).toBe(false);
|
31
|
+
});
|
32
|
+
});
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { expect, test, describe } from '@jest/globals';
|
2
|
+
import { is_whitespace_char } from '../../../index.mjs';
|
3
|
+
|
4
|
+
describe('Функция is_whitespace_char', () => {
|
5
|
+
test('Должна возвращать true для пробельного символа', () => {
|
6
|
+
expect(is_whitespace_char(' ')).toBe(true);
|
7
|
+
expect(is_whitespace_char('\t')).toBe(true);
|
8
|
+
expect(is_whitespace_char('\n')).toBe(true);
|
9
|
+
});
|
10
|
+
|
11
|
+
test('Должна возвращать false для непробельного символа', () => {
|
12
|
+
expect(is_whitespace_char('a')).toBe(false);
|
13
|
+
expect(is_whitespace_char('1')).toBe(false);
|
14
|
+
expect(is_whitespace_char('!')).toBe(false);
|
15
|
+
});
|
16
|
+
|
17
|
+
test('Должна возвращать false для строки из нескольких символов', () => {
|
18
|
+
expect(is_whitespace_char('abc')).toBe(false);
|
19
|
+
});
|
20
|
+
|
21
|
+
test('Должна возвращать false для пустой строки', () => {
|
22
|
+
expect(is_whitespace_char('')).toBe(false);
|
23
|
+
});
|
24
|
+
|
25
|
+
test('Должна возвращать false для значения, не являющегося строкой', () => {
|
26
|
+
expect(is_whitespace_char(1)).toBe(false);
|
27
|
+
expect(is_whitespace_char(null)).toBe(false);
|
28
|
+
expect(is_whitespace_char(undefined)).toBe(false);
|
29
|
+
expect(is_whitespace_char({})).toBe(false);
|
30
|
+
expect(is_whitespace_char([])).toBe(false);
|
31
|
+
});
|
32
|
+
});
|
@@ -0,0 +1,100 @@
|
|
1
|
+
import { expect, test, describe } from '@jest/globals';
|
2
|
+
import { natcompare } from '../../../index.mjs';
|
3
|
+
|
4
|
+
describe('Функция natcompare', () => {
|
5
|
+
test('Должна корректно сравнивать строки с числовыми значениями', () => {
|
6
|
+
expect(natcompare('10', '2')).toBeGreaterThan(0);
|
7
|
+
expect(natcompare('2', '10')).toBeLessThan(0);
|
8
|
+
expect(natcompare('10', '10')).toBe(0);
|
9
|
+
});
|
10
|
+
|
11
|
+
test('Должна корректно сравнивать строки с ведущими нулями', () => {
|
12
|
+
expect(natcompare('0010', '10')).toBe(0);
|
13
|
+
expect(natcompare('010', '10')).toBe(0);
|
14
|
+
expect(natcompare('10', '0010')).toBe(0);
|
15
|
+
});
|
16
|
+
|
17
|
+
test('Должна корректно сравнивать строки с пробелами', () => {
|
18
|
+
expect(natcompare(' 10', '10')).toBe(0);
|
19
|
+
expect(natcompare('10', ' 10')).toBe(0);
|
20
|
+
expect(natcompare(' 10', ' 10')).toBe(0);
|
21
|
+
});
|
22
|
+
|
23
|
+
test('Должна корректно сравнивать строки с буквами и числами', () => {
|
24
|
+
expect(natcompare('a10', 'a2')).toBeGreaterThan(0);
|
25
|
+
expect(natcompare('a2', 'a10')).toBeLessThan(0);
|
26
|
+
expect(natcompare('a10', 'a10')).toBe(0);
|
27
|
+
});
|
28
|
+
|
29
|
+
test('Должна корректно сравнивать строки с разными символами', () => {
|
30
|
+
expect(natcompare('10-', '10+')).toBeGreaterThan(0);
|
31
|
+
expect(natcompare('10+', '10-')).toBeLessThan(0);
|
32
|
+
expect(natcompare('10-', '10-')).toBe(0);
|
33
|
+
});
|
34
|
+
|
35
|
+
test('Должна корректно сравнивать строки с одинаковыми числовыми значениями и разными буквами', () => {
|
36
|
+
expect(natcompare('10a', '10b')).toBeLessThan(0);
|
37
|
+
expect(natcompare('10b', '10a')).toBeGreaterThan(0);
|
38
|
+
expect(natcompare('10a', '10a')).toBe(0);
|
39
|
+
});
|
40
|
+
|
41
|
+
test('Должна корректно сравнивать строки с одинаковыми числовыми значениями и разными регистрами', () => {
|
42
|
+
expect(natcompare('10A', '10a')).toBeLessThan(0);
|
43
|
+
expect(natcompare('10a', '10A')).toBeGreaterThan(0);
|
44
|
+
expect(natcompare('10A', '10A')).toBe(0);
|
45
|
+
});
|
46
|
+
|
47
|
+
test('Должна корректно сравнивать строки с одинаковыми числовыми значениями и разными пробелами', () => {
|
48
|
+
expect(natcompare('10 ', '10')).toBe(0);
|
49
|
+
expect(natcompare('10', '10 ')).toBe(0);
|
50
|
+
expect(natcompare('10 ', '10 ')).toBe(0);
|
51
|
+
});
|
52
|
+
|
53
|
+
test('Должна корректно сравнивать строки с одинаковыми буквами и разными числовыми значениями', () => {
|
54
|
+
expect(natcompare('a10', 'a2')).toBeGreaterThan(0);
|
55
|
+
expect(natcompare('a2', 'a10')).toBeLessThan(0);
|
56
|
+
expect(natcompare('a10', 'a10')).toBe(0);
|
57
|
+
});
|
58
|
+
|
59
|
+
test('Должна корректно сравнивать строки с одинаковыми буквами и одинаковыми числовыми значениями', () => {
|
60
|
+
expect(natcompare('a10', 'a10')).toBe(0);
|
61
|
+
expect(natcompare('a10', 'a10')).toBe(0);
|
62
|
+
expect(natcompare('a10', 'a10')).toBe(0);
|
63
|
+
});
|
64
|
+
|
65
|
+
test('Должна корректно сравнивать строки с разными длинами', () => {
|
66
|
+
expect(natcompare('a', 'aa')).toBeLessThan(0);
|
67
|
+
expect(natcompare('aa', 'a')).toBeGreaterThan(0);
|
68
|
+
expect(natcompare('a', 'a')).toBe(0);
|
69
|
+
});
|
70
|
+
|
71
|
+
test('Должна корректно сравнивать строки с одинаковыми длинами и разными символами', () => {
|
72
|
+
expect(natcompare('a1', 'a2')).toBeLessThan(0);
|
73
|
+
expect(natcompare('a2', 'a1')).toBeGreaterThan(0);
|
74
|
+
expect(natcompare('a1', 'a1')).toBe(0);
|
75
|
+
});
|
76
|
+
|
77
|
+
test('Должна корректно сравнивать строки с одинаковыми длинами и одинаковыми символами', () => {
|
78
|
+
expect(natcompare('a1', 'a1')).toBe(0);
|
79
|
+
expect(natcompare('a1', 'a1')).toBe(0);
|
80
|
+
expect(natcompare('a1', 'a1')).toBe(0);
|
81
|
+
});
|
82
|
+
|
83
|
+
test('Должна корректно сравнивать строки с числами и буквами в разных позициях', () => {
|
84
|
+
expect(natcompare('a1b2', 'a1b10')).toBeLessThan(0);
|
85
|
+
expect(natcompare('a1b10', 'a1b2')).toBeGreaterThan(0);
|
86
|
+
expect(natcompare('a1b2', 'a1b2')).toBe(0);
|
87
|
+
});
|
88
|
+
|
89
|
+
test('Должна корректно сравнивать строки с числами и буквами в разных позициях и разными регистрами', () => {
|
90
|
+
expect(natcompare('a1B2', 'a1b10')).toBeLessThan(0);
|
91
|
+
expect(natcompare('a1b10', 'a1B2')).toBeGreaterThan(0);
|
92
|
+
expect(natcompare('a1B2', 'a1B2')).toBe(0);
|
93
|
+
});
|
94
|
+
|
95
|
+
test('Должна корректно сравнивать строки с числами и буквами в разных позициях и разными символами', () => {
|
96
|
+
expect(natcompare('a1-b2', 'a1+b10')).toBeLessThan(0);
|
97
|
+
expect(natcompare('a1+b10', 'a1-b2')).toBeGreaterThan(0);
|
98
|
+
expect(natcompare('a1-b2', 'a1-b2')).toBe(0);
|
99
|
+
});
|
100
|
+
});
|