@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.
Files changed (355) hide show
  1. package/CHANGELOG.md +319 -1
  2. package/docs/classes/Expect/toBe.md +61 -0
  3. package/docs/classes/Expect/toBeArray.md +52 -0
  4. package/docs/classes/Expect/toBeAssoc.md +53 -0
  5. package/docs/classes/Expect/toBeBigInt.md +52 -0
  6. package/docs/classes/Expect/toBeBool.md +53 -0
  7. package/docs/classes/Expect/toBeBoolean.md +53 -0
  8. package/docs/classes/Expect/toBeChar.md +53 -0
  9. package/docs/classes/Expect/toBeClass.md +53 -0
  10. package/docs/classes/Expect/toBeFloat.md +53 -0
  11. package/docs/classes/Expect/toBeFunction.md +52 -0
  12. package/docs/classes/Expect/toBeInfinity.md +53 -0
  13. package/docs/classes/Expect/toBeInt.md +53 -0
  14. package/docs/classes/Expect/toBeInteger.md +53 -0
  15. package/docs/classes/Expect/toBeList.md +53 -0
  16. package/docs/classes/Expect/toBeNaN.md +53 -0
  17. package/docs/classes/Expect/toBeNull.md +51 -0
  18. package/docs/classes/Expect/toBeNumber.md +52 -0
  19. package/docs/classes/Expect/toBeNumeric.md +53 -0
  20. package/docs/classes/Expect/toBeObject.md +52 -0
  21. package/docs/classes/Expect/toBeScalar.md +53 -0
  22. package/docs/classes/Expect/toBeString.md +52 -0
  23. package/docs/classes/Expect/toBeSymbol.md +53 -0
  24. package/docs/classes/Expect/toBeUndefined.md +54 -0
  25. package/docs/classes/Expect/toEqual.md +69 -0
  26. package/docs/classes/Expect/toStrictEqual.md +70 -0
  27. package/docs/classes/Expect.md +87 -0
  28. package/docs/classes/Type/expectArray.md +63 -0
  29. package/docs/classes/Type/expectAssoc.md +65 -0
  30. package/docs/classes/Type/expectBigInt.md +63 -0
  31. package/docs/classes/Type/expectBool.md +65 -0
  32. package/docs/classes/Type/expectBoolean.md +65 -0
  33. package/docs/classes/Type/expectChar.md +63 -0
  34. package/docs/classes/Type/expectClass.md +63 -0
  35. package/docs/classes/Type/expectFloat.md +68 -0
  36. package/docs/classes/Type/expectFunction.md +63 -0
  37. package/docs/classes/Type/expectInfinity.md +65 -0
  38. package/docs/classes/Type/expectInt.md +64 -0
  39. package/docs/classes/Type/expectInteger.md +64 -0
  40. package/docs/classes/Type/expectList.md +63 -0
  41. package/docs/classes/Type/expectNaN.md +63 -0
  42. package/docs/classes/Type/expectNull.md +63 -0
  43. package/docs/classes/Type/expectNumber.md +63 -0
  44. package/docs/classes/Type/expectNumeric.md +63 -0
  45. package/docs/classes/Type/expectObject.md +64 -0
  46. package/docs/classes/Type/expectScalar.md +63 -0
  47. package/docs/classes/Type/expectString.md +63 -0
  48. package/docs/classes/Type/expectSymbol.md +63 -0
  49. package/docs/classes/Type/expectUndefined.md +63 -0
  50. package/docs/classes/Type.md +101 -2
  51. package/docs/classes.md +2 -1
  52. package/docs/helpers/array/array_chunk.md +80 -0
  53. package/docs/helpers/array/array_chunk_with_keys.md +81 -0
  54. package/docs/helpers/array/array_column.md +110 -0
  55. package/docs/helpers/array/array_combine.md +77 -0
  56. package/docs/helpers/array/array_count_values.md +71 -0
  57. package/docs/helpers/array/array_diff.md +97 -0
  58. package/docs/helpers/array/array_diff_assoc.md +81 -0
  59. package/docs/helpers/array/array_diff_key.md +81 -0
  60. package/docs/helpers/array/array_diff_uassoc.md +101 -0
  61. package/docs/helpers/array/array_diff_ukey.md +101 -0
  62. package/docs/helpers/array/array_fill.md +81 -0
  63. package/docs/helpers/array/array_fill_keys.md +73 -0
  64. package/docs/helpers/array/array_filter.md +79 -0
  65. package/docs/helpers/array/array_flip.md +70 -0
  66. package/docs/helpers/array/array_index_max.md +78 -0
  67. package/docs/helpers/array/array_index_min.md +78 -0
  68. package/docs/helpers/array/array_intersect.md +91 -0
  69. package/docs/helpers/array/array_intersect_assoc.md +91 -0
  70. package/docs/helpers/array/array_intersect_key.md +91 -0
  71. package/docs/helpers/array/array_intersect_uassoc.md +101 -0
  72. package/docs/helpers/array/array_intersect_ukey.md +101 -0
  73. package/docs/helpers/array/array_key_exists.md +73 -0
  74. package/docs/helpers/array/array_key_first.md +62 -0
  75. package/docs/helpers/array/array_key_last.md +62 -0
  76. package/docs/helpers/array/array_key_to_lower_case.md +57 -0
  77. package/docs/helpers/array/array_key_to_upper_case.md +57 -0
  78. package/docs/helpers/array/array_keys.md +62 -0
  79. package/docs/helpers/array/array_map.md +69 -0
  80. package/docs/helpers/array/array_merge.md +67 -0
  81. package/docs/helpers/array/array_merge_recursive.md +86 -0
  82. package/docs/helpers/array/array_pad.md +83 -0
  83. package/docs/helpers/array/array_pop.md +64 -0
  84. package/docs/helpers/array/array_product.md +62 -0
  85. package/docs/helpers/array/array_push.md +57 -0
  86. package/docs/helpers/array/array_rand.md +99 -0
  87. package/docs/helpers/array/array_reduce.md +77 -0
  88. package/docs/helpers/array/array_replace.md +85 -0
  89. package/docs/helpers/array/array_replace_recursive.md +87 -0
  90. package/docs/helpers/array/array_reverse.md +55 -0
  91. package/docs/helpers/array/array_search.md +74 -0
  92. package/docs/helpers/array/array_shift.md +64 -0
  93. package/docs/helpers/array/array_slice.md +65 -0
  94. package/docs/helpers/array/array_splice.md +103 -0
  95. package/docs/helpers/array/array_sum.md +55 -0
  96. package/docs/helpers/array/array_udiff.md +97 -0
  97. package/docs/helpers/array/array_udiff_assoc.md +101 -0
  98. package/docs/helpers/array/array_udiff_uassoc.md +88 -0
  99. package/docs/helpers/array/array_uintersect.md +101 -0
  100. package/docs/helpers/array/array_uintersect_assoc.md +102 -0
  101. package/docs/helpers/array/array_uintersect_uassoc.md +135 -0
  102. package/docs/helpers/array/array_unique.md +54 -0
  103. package/docs/helpers/array/array_unshift.md +58 -0
  104. package/docs/helpers/array/array_values.md +54 -0
  105. package/docs/helpers/array/array_walk.md +87 -0
  106. package/docs/helpers/array/array_walk_recursive.md +93 -0
  107. package/docs/helpers/array/count.md +54 -0
  108. package/docs/helpers/array/in_array.md +65 -0
  109. package/docs/helpers/array/natsort.md +60 -0
  110. package/docs/helpers/array/range.md +76 -0
  111. package/docs/helpers/array/shuffle.md +74 -0
  112. package/docs/helpers/array/sort.md +79 -0
  113. package/docs/helpers/expect.md +58 -0
  114. package/docs/helpers/expect_array.md +63 -0
  115. package/docs/helpers/expect_assoc.md +65 -0
  116. package/docs/helpers/expect_bigint.md +63 -0
  117. package/docs/helpers/expect_bool.md +65 -0
  118. package/docs/helpers/expect_boolean.md +65 -0
  119. package/docs/helpers/expect_char.md +63 -0
  120. package/docs/helpers/expect_class.md +63 -0
  121. package/docs/helpers/expect_float.md +65 -0
  122. package/docs/helpers/expect_function.md +63 -0
  123. package/docs/helpers/expect_infinity.md +65 -0
  124. package/docs/helpers/expect_int.md +65 -0
  125. package/docs/helpers/expect_integer.md +65 -0
  126. package/docs/helpers/expect_list.md +63 -0
  127. package/docs/helpers/expect_nan.md +63 -0
  128. package/docs/helpers/expect_null.md +63 -0
  129. package/docs/helpers/expect_number.md +63 -0
  130. package/docs/helpers/expect_numeric.md +63 -0
  131. package/docs/helpers/expect_object.md +64 -0
  132. package/docs/helpers/expect_scalar.md +63 -0
  133. package/docs/helpers/expect_string.md +63 -0
  134. package/docs/helpers/expect_symbol.md +63 -0
  135. package/docs/helpers/expect_undefined.md +64 -0
  136. package/docs/helpers/is_char.md +84 -0
  137. package/docs/helpers/is_equal.md +75 -0
  138. package/docs/helpers/string/is_digit_char.md +70 -0
  139. package/docs/helpers/string/is_whitespace_char.md +70 -0
  140. package/docs/helpers/string/natcompare.md +69 -0
  141. package/docs/helpers/string/natcompare_numeric.md +70 -0
  142. package/docs/helpers.md +172 -1
  143. package/index.mjs +91 -1
  144. package/package.json +1 -1
  145. package/prettier.config.mjs +2 -1
  146. package/src/classes/Expect.mjs +1445 -0
  147. package/src/classes/Type.mjs +2739 -1284
  148. package/src/constants.mjs +83 -14
  149. package/src/helpers/array/array_chunk.mjs +102 -0
  150. package/src/helpers/array/array_chunk_with_keys.mjs +102 -0
  151. package/src/helpers/array/array_column.mjs +131 -0
  152. package/src/helpers/array/array_combine.mjs +26 -0
  153. package/src/helpers/array/array_count_values.mjs +82 -0
  154. package/src/helpers/array/array_diff.mjs +77 -0
  155. package/src/helpers/array/array_diff_assoc.mjs +56 -0
  156. package/src/helpers/array/array_diff_key.mjs +56 -0
  157. package/src/helpers/array/array_diff_uassoc.mjs +76 -0
  158. package/src/helpers/array/array_diff_ukey.mjs +71 -0
  159. package/src/helpers/array/array_fill.mjs +108 -0
  160. package/src/helpers/array/array_fill_keys.mjs +90 -0
  161. package/src/helpers/array/array_filter.mjs +105 -0
  162. package/src/helpers/array/array_flip.mjs +58 -0
  163. package/src/helpers/array/array_index_max.mjs +82 -0
  164. package/src/helpers/array/array_index_min.mjs +82 -0
  165. package/src/helpers/array/array_intersect.mjs +71 -0
  166. package/src/helpers/array/array_intersect_assoc.mjs +67 -0
  167. package/src/helpers/array/array_intersect_key.mjs +67 -0
  168. package/src/helpers/array/array_intersect_uassoc.mjs +77 -0
  169. package/src/helpers/array/array_intersect_ukey.mjs +72 -0
  170. package/src/helpers/array/array_key_exists.mjs +83 -0
  171. package/src/helpers/array/array_key_first.mjs +73 -0
  172. package/src/helpers/array/array_key_last.mjs +74 -0
  173. package/src/helpers/array/array_key_to_lower_case.mjs +71 -0
  174. package/src/helpers/array/array_key_to_upper_case.mjs +71 -0
  175. package/src/helpers/array/array_keys.mjs +65 -0
  176. package/src/helpers/array/array_map.mjs +84 -0
  177. package/src/helpers/array/array_merge.mjs +95 -0
  178. package/src/helpers/array/array_merge_recursive.mjs +153 -0
  179. package/src/helpers/array/array_pad.mjs +105 -0
  180. package/src/helpers/array/array_pop.mjs +82 -0
  181. package/src/helpers/array/array_product.mjs +67 -0
  182. package/src/helpers/array/array_push.mjs +75 -0
  183. package/src/helpers/array/array_rand.mjs +129 -0
  184. package/src/helpers/array/array_reduce.mjs +90 -0
  185. package/src/helpers/array/array_replace.mjs +25 -0
  186. package/src/helpers/array/array_replace_recursive.mjs +109 -0
  187. package/src/helpers/array/array_reverse.mjs +62 -0
  188. package/src/helpers/array/array_search.mjs +104 -0
  189. package/src/helpers/array/array_shift.mjs +78 -0
  190. package/src/helpers/array/array_slice.mjs +99 -0
  191. package/src/helpers/array/array_splice.mjs +218 -0
  192. package/src/helpers/array/array_sum.mjs +60 -0
  193. package/src/helpers/array/array_udiff.mjs +91 -0
  194. package/src/helpers/array/array_udiff_assoc.mjs +71 -0
  195. package/src/helpers/array/array_udiff_uassoc.mjs +124 -0
  196. package/src/helpers/array/array_uintersect.mjs +72 -0
  197. package/src/helpers/array/array_uintersect_assoc.mjs +77 -0
  198. package/src/helpers/array/array_uintersect_uassoc.mjs +121 -0
  199. package/src/helpers/array/array_unique.mjs +77 -0
  200. package/src/helpers/array/array_unshift.mjs +64 -0
  201. package/src/helpers/array/array_values.mjs +57 -0
  202. package/src/helpers/array/array_walk.mjs +95 -0
  203. package/src/helpers/array/array_walk_recursive.mjs +104 -0
  204. package/src/helpers/array/count.mjs +57 -0
  205. package/src/helpers/array/in_array.mjs +67 -0
  206. package/src/helpers/array/natsort.mjs +62 -0
  207. package/src/helpers/array/range.mjs +121 -0
  208. package/src/helpers/array/shuffle.mjs +73 -0
  209. package/src/helpers/array/sort.mjs +69 -0
  210. package/src/helpers/expect.mjs +44 -0
  211. package/src/helpers/expect_array.mjs +66 -0
  212. package/src/helpers/expect_assoc.mjs +66 -0
  213. package/src/helpers/expect_bigint.mjs +66 -0
  214. package/src/helpers/expect_bool.mjs +66 -0
  215. package/src/helpers/expect_boolean.mjs +57 -0
  216. package/src/helpers/expect_char.mjs +66 -0
  217. package/src/helpers/expect_class.mjs +66 -0
  218. package/src/helpers/expect_float.mjs +66 -0
  219. package/src/helpers/expect_function.mjs +66 -0
  220. package/src/helpers/expect_infinity.mjs +66 -0
  221. package/src/helpers/expect_int.mjs +66 -0
  222. package/src/helpers/expect_integer.mjs +57 -0
  223. package/src/helpers/expect_list.mjs +66 -0
  224. package/src/helpers/expect_nan.mjs +66 -0
  225. package/src/helpers/expect_null.mjs +66 -0
  226. package/src/helpers/expect_number.mjs +66 -0
  227. package/src/helpers/expect_numeric.mjs +66 -0
  228. package/src/helpers/expect_object.mjs +67 -0
  229. package/src/helpers/expect_scalar.mjs +66 -0
  230. package/src/helpers/expect_string.mjs +65 -0
  231. package/src/helpers/expect_symbol.mjs +66 -0
  232. package/src/helpers/expect_undefined.mjs +66 -0
  233. package/src/helpers/is_char.mjs +54 -0
  234. package/src/helpers/is_equal.mjs +94 -0
  235. package/src/helpers/string/is_digit_char.mjs +60 -0
  236. package/src/helpers/string/is_whitespace_char.mjs +54 -0
  237. package/src/helpers/string/natcompare.mjs +107 -0
  238. package/src/helpers/string/natcompare_numeric.mjs +131 -0
  239. package/tests/classes/Expect/toBe.test.mjs +60 -0
  240. package/tests/classes/Expect/toBeArray.test.mjs +46 -0
  241. package/tests/classes/Expect/toBeAssoc.test.mjs +48 -0
  242. package/tests/classes/Expect/toBeBigInt.test.mjs +46 -0
  243. package/tests/classes/Expect/toBeBool.test.mjs +48 -0
  244. package/tests/classes/Expect/toBeBoolean.test.mjs +48 -0
  245. package/tests/classes/Expect/toBeChar.test.mjs +46 -0
  246. package/tests/classes/Expect/toBeClass.test.mjs +48 -0
  247. package/tests/classes/Expect/toBeFloat.test.mjs +48 -0
  248. package/tests/classes/Expect/toBeFunction.test.mjs +51 -0
  249. package/tests/classes/Expect/toBeInfinity.test.mjs +48 -0
  250. package/tests/classes/Expect/toBeInt.test.mjs +48 -0
  251. package/tests/classes/Expect/toBeInteger.test.mjs +48 -0
  252. package/tests/classes/Expect/toBeList.test.mjs +46 -0
  253. package/tests/classes/Expect/toBeNaN.test.mjs +46 -0
  254. package/tests/classes/Expect/toBeNull.test.mjs +46 -0
  255. package/tests/classes/Expect/toBeNumber.test.mjs +46 -0
  256. package/tests/classes/Expect/toBeNumeric.test.mjs +53 -0
  257. package/tests/classes/Expect/toBeObject.test.mjs +47 -0
  258. package/tests/classes/Expect/toBeScalar.test.mjs +63 -0
  259. package/tests/classes/Expect/toBeString.test.mjs +46 -0
  260. package/tests/classes/Expect/toBeSymbol.test.mjs +46 -0
  261. package/tests/classes/Expect/toBeUndefined.test.mjs +50 -0
  262. package/tests/classes/Expect/toEqual.test.mjs +66 -0
  263. package/tests/classes/Expect/toStrictEqual.test.mjs +73 -0
  264. package/tests/classes/Type.test.mjs +1320 -1262
  265. package/tests/helpers/array/array_chunk.test.mjs +49 -0
  266. package/tests/helpers/array/array_chunk_with_keys.test.mjs +45 -0
  267. package/tests/helpers/array/array_column.test.mjs +87 -0
  268. package/tests/helpers/array/array_combine.test.mjs +41 -0
  269. package/tests/helpers/array/array_count_values.test.mjs +40 -0
  270. package/tests/helpers/array/array_diff.test.mjs +78 -0
  271. package/tests/helpers/array/array_diff_assoc.test.mjs +64 -0
  272. package/tests/helpers/array/array_diff_key.test.mjs +64 -0
  273. package/tests/helpers/array/array_diff_uassoc.test.mjs +73 -0
  274. package/tests/helpers/array/array_diff_ukey.test.mjs +77 -0
  275. package/tests/helpers/array/array_fill.test.mjs +47 -0
  276. package/tests/helpers/array/array_fill_keys.test.mjs +35 -0
  277. package/tests/helpers/array/array_filter.test.mjs +38 -0
  278. package/tests/helpers/array/array_flip.test.mjs +33 -0
  279. package/tests/helpers/array/array_index_max.test.mjs +41 -0
  280. package/tests/helpers/array/array_index_min.test.mjs +41 -0
  281. package/tests/helpers/array/array_intersect.test.mjs +65 -0
  282. package/tests/helpers/array/array_intersect_assoc.test.mjs +65 -0
  283. package/tests/helpers/array/array_intersect_key.test.mjs +65 -0
  284. package/tests/helpers/array/array_intersect_uassoc.test.mjs +76 -0
  285. package/tests/helpers/array/array_intersect_ukey.test.mjs +74 -0
  286. package/tests/helpers/array/array_key_exists.test.mjs +36 -0
  287. package/tests/helpers/array/array_key_first.test.mjs +29 -0
  288. package/tests/helpers/array/array_key_last.test.mjs +29 -0
  289. package/tests/helpers/array/array_key_to_lower_case.test.mjs +23 -0
  290. package/tests/helpers/array/array_key_to_upper_case.test.mjs +23 -0
  291. package/tests/helpers/array/array_keys.test.mjs +27 -0
  292. package/tests/helpers/array/array_map.test.mjs +32 -0
  293. package/tests/helpers/array/array_merge.test.mjs +37 -0
  294. package/tests/helpers/array/array_merge_recursive.test.mjs +65 -0
  295. package/tests/helpers/array/array_pad.test.mjs +48 -0
  296. package/tests/helpers/array/array_pop.test.mjs +29 -0
  297. package/tests/helpers/array/array_product.test.mjs +33 -0
  298. package/tests/helpers/array/array_push.test.mjs +31 -0
  299. package/tests/helpers/array/array_rand.test.mjs +59 -0
  300. package/tests/helpers/array/array_reduce.test.mjs +44 -0
  301. package/tests/helpers/array/array_replace.test.mjs +46 -0
  302. package/tests/helpers/array/array_replace_recursive.test.mjs +46 -0
  303. package/tests/helpers/array/array_reverse.test.mjs +31 -0
  304. package/tests/helpers/array/array_search.test.mjs +48 -0
  305. package/tests/helpers/array/array_shift.test.mjs +29 -0
  306. package/tests/helpers/array/array_slice.test.mjs +49 -0
  307. package/tests/helpers/array/array_splice.test.mjs +67 -0
  308. package/tests/helpers/array/array_sum.test.mjs +27 -0
  309. package/tests/helpers/array/array_udiff.test.mjs +95 -0
  310. package/tests/helpers/array/array_udiff_assoc.test.mjs +77 -0
  311. package/tests/helpers/array/array_udiff_uassoc.test.mjs +89 -0
  312. package/tests/helpers/array/array_uintersect.test.mjs +78 -0
  313. package/tests/helpers/array/array_uintersect_assoc.test.mjs +80 -0
  314. package/tests/helpers/array/array_uintersect_uassoc.test.mjs +122 -0
  315. package/tests/helpers/array/array_unique.test.mjs +27 -0
  316. package/tests/helpers/array/array_unshift.test.mjs +31 -0
  317. package/tests/helpers/array/array_values.test.mjs +27 -0
  318. package/tests/helpers/array/array_walk.test.mjs +48 -0
  319. package/tests/helpers/array/array_walk_recursive.test.mjs +53 -0
  320. package/tests/helpers/array/count.test.mjs +27 -0
  321. package/tests/helpers/array/in_array.test.mjs +52 -0
  322. package/tests/helpers/array/natsort.test.mjs +71 -0
  323. package/tests/helpers/array/range.test.mjs +51 -0
  324. package/tests/helpers/array/shuffle.test.mjs +42 -0
  325. package/tests/helpers/array/sort.test.mjs +60 -0
  326. package/tests/helpers/array.test.mjs +58 -58
  327. package/tests/helpers/expect.test.mjs +95 -0
  328. package/tests/helpers/expect_array.test.mjs +71 -0
  329. package/tests/helpers/expect_assoc.test.mjs +61 -0
  330. package/tests/helpers/expect_bigint.test.mjs +63 -0
  331. package/tests/helpers/expect_bool.test.mjs +59 -0
  332. package/tests/helpers/expect_boolean.test.mjs +61 -0
  333. package/tests/helpers/expect_char.test.mjs +63 -0
  334. package/tests/helpers/expect_class.test.mjs +64 -0
  335. package/tests/helpers/expect_float.test.mjs +64 -0
  336. package/tests/helpers/expect_function.test.mjs +65 -0
  337. package/tests/helpers/expect_infinity.test.mjs +62 -0
  338. package/tests/helpers/expect_int.test.mjs +57 -0
  339. package/tests/helpers/expect_integer.test.mjs +59 -0
  340. package/tests/helpers/expect_list.test.mjs +73 -0
  341. package/tests/helpers/expect_nan.test.mjs +57 -0
  342. package/tests/helpers/expect_null.test.mjs +57 -0
  343. package/tests/helpers/expect_number.test.mjs +57 -0
  344. package/tests/helpers/expect_numeric.test.mjs +57 -0
  345. package/tests/helpers/expect_object.test.mjs +63 -0
  346. package/tests/helpers/expect_scalar.test.mjs +72 -0
  347. package/tests/helpers/expect_string.test.mjs +65 -0
  348. package/tests/helpers/expect_symbol.test.mjs +66 -0
  349. package/tests/helpers/expect_undefined.test.mjs +59 -0
  350. package/tests/helpers/is_char.test.mjs +40 -0
  351. package/tests/helpers/is_equal.test.mjs +110 -0
  352. package/tests/helpers/string/is_digit_char.test.mjs +32 -0
  353. package/tests/helpers/string/is_whitespace_char.test.mjs +32 -0
  354. package/tests/helpers/string/natcompare.test.mjs +100 -0
  355. package/tests/helpers/string/natcompare_numeric.test.mjs +110 -0
@@ -0,0 +1,122 @@
1
+ import { expect, test, describe } from '@jest/globals';
2
+ import { array_uintersect_uassoc } from '../../../index.mjs';
3
+
4
+ describe('Функция array_uintersect_uassoc', () => {
5
+ const value_compare_func = (a, b) => a === b;
6
+ const key_compare_func = (a, b) => a === b;
7
+
8
+ test('Должна возвращать элементы из первого массива, которые присутствуют в других массивах', () => {
9
+ const original_array = { a: 1, b: 2, c: 3 };
10
+ const array1 = { a: 1, b: 2 };
11
+ const array2 = { b: 2, c: 3 };
12
+ const result = array_uintersect_uassoc(
13
+ value_compare_func,
14
+ key_compare_func,
15
+ original_array,
16
+ array1,
17
+ array2,
18
+ );
19
+ expect(result).toEqual({ a: 1, b: 2, c: 3 });
20
+ });
21
+
22
+ test('Должна возвращать пустой объект, если все элементы первого массива отсутствуют в других массивах', () => {
23
+ const original_array = { a: 1, b: 2 };
24
+ const array1 = { c: 3, d: 4 };
25
+ const result = array_uintersect_uassoc(
26
+ value_compare_func,
27
+ key_compare_func,
28
+ original_array,
29
+ array1,
30
+ );
31
+ expect(result).toEqual({});
32
+ });
33
+
34
+ test('Должна корректно обрабатывать пустые массивы', () => {
35
+ const original_array = {};
36
+ const array1 = {};
37
+ const result = array_uintersect_uassoc(
38
+ value_compare_func,
39
+ key_compare_func,
40
+ original_array,
41
+ array1,
42
+ );
43
+ expect(result).toEqual({});
44
+ });
45
+
46
+ test('Должна выбрасывать ошибку, если переданное значение для value_compare_func не является функцией', () => {
47
+ expect(() => array_uintersect_uassoc('not a function', key_compare_func, {})).toThrow(
48
+ TypeError,
49
+ );
50
+ expect(() => array_uintersect_uassoc('not a function', key_compare_func, {})).toThrow(
51
+ 'Параметр "value_compare_func" должен быть функцией.',
52
+ );
53
+ });
54
+
55
+ test('Должна выбрасывать ошибку, если переданное значение для key_compare_func не является функцией', () => {
56
+ expect(() => array_uintersect_uassoc(value_compare_func, 'not a function', {})).toThrow(
57
+ TypeError,
58
+ );
59
+ expect(() => array_uintersect_uassoc(value_compare_func, 'not a function', {})).toThrow(
60
+ 'Параметр "key_compare_func" должен быть функцией.',
61
+ );
62
+ });
63
+
64
+ test('Должна выбрасывать ошибку, если переданное значение для original_array не является массивом', () => {
65
+ expect(() =>
66
+ array_uintersect_uassoc(value_compare_func, key_compare_func, 'not an array'),
67
+ ).toThrow(TypeError);
68
+ expect(() =>
69
+ array_uintersect_uassoc(value_compare_func, key_compare_func, 'not an array'),
70
+ ).toThrow('Параметр "original_array" должен быть массивом.');
71
+ });
72
+
73
+ test('Должна выбрасывать ошибку, если переданное значение для arrays не является массивом', () => {
74
+ expect(() =>
75
+ array_uintersect_uassoc(value_compare_func, key_compare_func, {}, 'not an array'),
76
+ ).toThrow(TypeError);
77
+ expect(() =>
78
+ array_uintersect_uassoc(value_compare_func, key_compare_func, {}, 'not an array'),
79
+ ).toThrow('Параметр "arrays" должен быть массивом.');
80
+ });
81
+
82
+ test('Должна корректно обрабатывать массивы с различными типами данных', () => {
83
+ const original_array = { a: 1, b: '2', c: true };
84
+ const array1 = { a: 1, b: 2, d: false };
85
+ const result = array_uintersect_uassoc(
86
+ value_compare_func,
87
+ key_compare_func,
88
+ original_array,
89
+ array1,
90
+ );
91
+ expect(result).toEqual({ a: 1 });
92
+ });
93
+
94
+ test('Должна корректно обрабатывать несколько массивов для сравнения', () => {
95
+ const original_array = { a: 1, b: 2, c: 3, d: 4 };
96
+ const array1 = { a: 1, b: 2 };
97
+ const array2 = { c: 3 };
98
+ const result = array_uintersect_uassoc(
99
+ value_compare_func,
100
+ key_compare_func,
101
+ original_array,
102
+ array1,
103
+ array2,
104
+ );
105
+ expect(result).toEqual({ a: 1, b: 2, c: 3 });
106
+ });
107
+
108
+ test('Должна корректно обрабатывать массивы с вложенными структурами', () => {
109
+ const original_array = {
110
+ a: { id: 1, data: [1, 2] },
111
+ b: { id: 2, data: [3, 4] },
112
+ };
113
+ const array1 = { a: { id: 1, data: [1, 2] } };
114
+ const result = array_uintersect_uassoc(
115
+ (a, b) => JSON.stringify(a) === JSON.stringify(b),
116
+ key_compare_func,
117
+ original_array,
118
+ array1,
119
+ );
120
+ expect(result).toEqual({ a: { id: 1, data: [1, 2] } });
121
+ });
122
+ });
@@ -0,0 +1,27 @@
1
+ import { expect, test, describe } from '@jest/globals';
2
+ import { array_unique } from '../../../index.mjs';
3
+
4
+ describe('Функция array_unique', () => {
5
+ test('Должна удалять дублирующиеся значения из обычного массива', () => {
6
+ const array = [1, 2, 2, 3, 4, 4, 5];
7
+ const result = array_unique(array);
8
+ expect(result).toEqual([1, 2, 3, 4, 5]);
9
+ });
10
+
11
+ test('Должна удалять дублирующиеся значения из ассоциативного массива', () => {
12
+ const array = { a: 1, b: 2, c: 2, d: 3, e: 4, f: 4, g: 5 };
13
+ const result = array_unique(array);
14
+ expect(result).toEqual({ a: 1, b: 2, d: 3, e: 4, g: 5 });
15
+ });
16
+
17
+ test('Должна возвращать пустой массив, если исходный массив пустой', () => {
18
+ const array = [];
19
+ const result = array_unique(array);
20
+ expect(result).toEqual([]);
21
+ });
22
+
23
+ test('Должна выбрасывать ошибку, если параметр не является массивом', () => {
24
+ expect(() => array_unique('not an array')).toThrow(TypeError);
25
+ expect(() => array_unique('not an array')).toThrow('Параметр "arr" должен быть массивом.');
26
+ });
27
+ });
@@ -0,0 +1,31 @@
1
+ import { expect, test, describe } from '@jest/globals';
2
+ import { array_unshift } from '../../../index.mjs';
3
+
4
+ describe('Функция array_unshift', () => {
5
+ test('Должна добавлять элементы в начало обычного массива', () => {
6
+ const array = [2, 3, 4];
7
+ const result = array_unshift(array, 0, 1);
8
+ expect(result).toBe(5);
9
+ expect(array).toEqual([0, 1, 2, 3, 4]);
10
+ });
11
+
12
+ test('Должна добавлять элементы в начало ассоциативного массива', () => {
13
+ const array = { b: 2, c: 3 };
14
+ const result = array_unshift(array, { a: 1 });
15
+ expect(result).toBe(3);
16
+ expect(array).toEqual({ a: 1, b: 2, c: 3 });
17
+ });
18
+
19
+ test('Должна возвращать новую длину массива после добавления элементов', () => {
20
+ const array = [1, 2, 3];
21
+ const result = array_unshift(array, 0);
22
+ expect(result).toBe(4);
23
+ });
24
+
25
+ test('Должна выбрасывать ошибку, если параметр не является массивом', () => {
26
+ expect(() => array_unshift('not an array', 1)).toThrow(TypeError);
27
+ expect(() => array_unshift('not an array', 1)).toThrow(
28
+ 'Параметр "arr" должен быть массивом.',
29
+ );
30
+ });
31
+ });
@@ -0,0 +1,27 @@
1
+ import { expect, test, describe } from '@jest/globals';
2
+ import { array_values } from '../../../index.mjs';
3
+
4
+ describe('Функция array_values', () => {
5
+ test('Должна возвращать значения из обычного массива', () => {
6
+ const array = [1, 2, 3];
7
+ const result = array_values(array);
8
+ expect(result).toEqual([1, 2, 3]);
9
+ });
10
+
11
+ test('Должна возвращать значения из ассоциативного массива', () => {
12
+ const array = { a: 1, b: 2, c: 3 };
13
+ const result = array_values(array);
14
+ expect(result).toEqual([1, 2, 3]);
15
+ });
16
+
17
+ test('Должна возвращать пустой массив, если исходный массив пустой', () => {
18
+ const array = [];
19
+ const result = array_values(array);
20
+ expect(result).toEqual([]);
21
+ });
22
+
23
+ test('Должна выбрасывать ошибку, если параметр не является массивом', () => {
24
+ expect(() => array_values('not an array')).toThrow(TypeError);
25
+ expect(() => array_values('not an array')).toThrow('Параметр "arr" должен быть массивом.');
26
+ });
27
+ });
@@ -0,0 +1,48 @@
1
+ import { expect, test, describe, jest } from '@jest/globals';
2
+ import { array_walk } from '../../../index.mjs';
3
+
4
+ describe('Функция array_walk', () => {
5
+ test('Должна применять функцию к каждому элементу обычного массива', () => {
6
+ const array = [1, 2, 3];
7
+ const callback = jest.fn();
8
+ array_walk(array, callback);
9
+ expect(callback).toHaveBeenCalledTimes(3);
10
+ expect(callback).toHaveBeenCalledWith(1, '0', null);
11
+ expect(callback).toHaveBeenCalledWith(2, '1', null);
12
+ expect(callback).toHaveBeenCalledWith(3, '2', null);
13
+ });
14
+
15
+ test('Должна применять функцию к каждому элементу ассоциативного массива', () => {
16
+ const array = { a: 1, b: 2, c: 3 };
17
+ const callback = jest.fn();
18
+ array_walk(array, callback);
19
+ expect(callback).toHaveBeenCalledTimes(3);
20
+ expect(callback).toHaveBeenCalledWith(1, 'a', null);
21
+ expect(callback).toHaveBeenCalledWith(2, 'b', null);
22
+ expect(callback).toHaveBeenCalledWith(3, 'c', null);
23
+ });
24
+
25
+ test('Должна передавать дополнительный аргумент в функцию обратного вызова', () => {
26
+ const array = [1, 2, 3];
27
+ const callback = jest.fn();
28
+ array_walk(array, callback, 'дополнительный аргумент');
29
+ expect(callback).toHaveBeenCalledTimes(3);
30
+ expect(callback).toHaveBeenCalledWith(1, '0', 'дополнительный аргумент');
31
+ expect(callback).toHaveBeenCalledWith(2, '1', 'дополнительный аргумент');
32
+ expect(callback).toHaveBeenCalledWith(3, '2', 'дополнительный аргумент');
33
+ });
34
+
35
+ test('Должна выбрасывать ошибку, если параметр не является массивом', () => {
36
+ expect(() => array_walk('not an array', () => {})).toThrow(TypeError);
37
+ expect(() => array_walk('not an array', () => {})).toThrow(
38
+ 'Параметр "arr" должен быть массивом.',
39
+ );
40
+ });
41
+
42
+ test('Должна выбрасывать ошибку, если параметр callback не является функцией', () => {
43
+ expect(() => array_walk([], 'not a function')).toThrow(TypeError);
44
+ expect(() => array_walk([], 'not a function')).toThrow(
45
+ 'Параметр "callback" должен быть функцией.',
46
+ );
47
+ });
48
+ });
@@ -0,0 +1,53 @@
1
+ import { expect, test, describe, jest } from '@jest/globals';
2
+ import { array_walk_recursive } from '../../../index.mjs';
3
+
4
+ describe('Функция array_walk_recursive', () => {
5
+ test('Должна применять функцию к каждому элементу обычного массива рекурсивно', () => {
6
+ const array = [1, 2, [3, 4], 5];
7
+ const callback = jest.fn();
8
+ array_walk_recursive(array, callback);
9
+ expect(callback).toHaveBeenCalledTimes(5);
10
+ expect(callback).toHaveBeenCalledWith(1, '0', null);
11
+ expect(callback).toHaveBeenCalledWith(2, '1', null);
12
+ expect(callback).toHaveBeenCalledWith(3, '0', null);
13
+ expect(callback).toHaveBeenCalledWith(4, '1', null);
14
+ expect(callback).toHaveBeenCalledWith(5, '3', null);
15
+ });
16
+
17
+ test('Должна применять функцию к каждому элементу ассоциативного массива рекурсивно', () => {
18
+ const array = { a: 1, b: { c: 2, d: 3 }, e: 4 };
19
+ const callback = jest.fn();
20
+ array_walk_recursive(array, callback);
21
+ expect(callback).toHaveBeenCalledTimes(4);
22
+ expect(callback).toHaveBeenCalledWith(1, 'a', null);
23
+ expect(callback).toHaveBeenCalledWith(2, 'c', null);
24
+ expect(callback).toHaveBeenCalledWith(3, 'd', null);
25
+ expect(callback).toHaveBeenCalledWith(4, 'e', null);
26
+ });
27
+
28
+ test('Должна передавать дополнительный аргумент в функцию обратного вызова', () => {
29
+ const array = [1, 2, [3, 4], 5];
30
+ const callback = jest.fn();
31
+ array_walk_recursive(array, callback, 'дополнительный аргумент');
32
+ expect(callback).toHaveBeenCalledTimes(5);
33
+ expect(callback).toHaveBeenCalledWith(1, '0', 'дополнительный аргумент');
34
+ expect(callback).toHaveBeenCalledWith(2, '1', 'дополнительный аргумент');
35
+ expect(callback).toHaveBeenCalledWith(3, '0', 'дополнительный аргумент');
36
+ expect(callback).toHaveBeenCalledWith(4, '1', 'дополнительный аргумент');
37
+ expect(callback).toHaveBeenCalledWith(5, '3', 'дополнительный аргумент');
38
+ });
39
+
40
+ test('Должна выбрасывать ошибку, если параметр не является массивом', () => {
41
+ expect(() => array_walk_recursive('not an array', () => {})).toThrow(TypeError);
42
+ expect(() => array_walk_recursive('not an array', () => {})).toThrow(
43
+ 'Параметр "arr" должен быть массивом.',
44
+ );
45
+ });
46
+
47
+ test('Должна выбрасывать ошибку, если параметр callback не является функцией', () => {
48
+ expect(() => array_walk_recursive([], 'not a function')).toThrow(TypeError);
49
+ expect(() => array_walk_recursive([], 'not a function')).toThrow(
50
+ 'Параметр "callback" должен быть функцией.',
51
+ );
52
+ });
53
+ });
@@ -0,0 +1,27 @@
1
+ import { expect, test, describe } from '@jest/globals';
2
+ import { count } from '../../../index.mjs';
3
+
4
+ describe('Функция count', () => {
5
+ test('Должна возвращать количество элементов в обычном массиве', () => {
6
+ const array = [1, 2, 3, 4, 5];
7
+ const result = count(array);
8
+ expect(result).toBe(5);
9
+ });
10
+
11
+ test('Должна возвращать количество элементов в ассоциативном массиве', () => {
12
+ const array = { a: 1, b: 2, c: 3 };
13
+ const result = count(array);
14
+ expect(result).toBe(3);
15
+ });
16
+
17
+ test('Должна возвращать 0 для пустого массива', () => {
18
+ const array = [];
19
+ const result = count(array);
20
+ expect(result).toBe(0);
21
+ });
22
+
23
+ test('Должна выбрасывать ошибку, если параметр не является массивом', () => {
24
+ expect(() => count('not an array')).toThrow(TypeError);
25
+ expect(() => count('not an array')).toThrow('Параметр "arr" должен быть массивом.');
26
+ });
27
+ });
@@ -0,0 +1,52 @@
1
+ import { expect, test, describe } from '@jest/globals';
2
+ import { in_array } from '../../../index.mjs';
3
+
4
+ describe('Функция in_array', () => {
5
+ test('Должна возвращать true, если значение существует в обычном массиве', () => {
6
+ const array = [1, 2, 3, 4, 5];
7
+ const result = in_array(array, 3);
8
+ expect(result).toBe(true);
9
+ });
10
+
11
+ test('Должна возвращать true, если значение существует в ассоциативном массиве', () => {
12
+ const array = { a: 1, b: 2, c: 3 };
13
+ const result = in_array(array, 2);
14
+ expect(result).toBe(true);
15
+ });
16
+
17
+ test('Должна возвращать false, если значение не существует в массиве', () => {
18
+ const array = [1, 2, 3];
19
+ const result = in_array(array, 4);
20
+ expect(result).toBe(false);
21
+ });
22
+
23
+ test('Должна возвращать false, если значение не существует в ассоциативном массиве', () => {
24
+ const array = { a: 1, b: 2, c: 3 };
25
+ const result = in_array(array, 4);
26
+ expect(result).toBe(false);
27
+ });
28
+
29
+ test('Должна возвращать true, если значение существует в массиве с использованием строгого сравнения', () => {
30
+ const array = [1, '2', 3];
31
+ const result = in_array(array, '2', true);
32
+ expect(result).toBe(true);
33
+ });
34
+
35
+ test('Должна возвращать false, если значение не существует в массиве с использованием строгого сравнения', () => {
36
+ const array = [1, '2', 3];
37
+ const result = in_array(array, 2, true);
38
+ expect(result).toBe(false);
39
+ });
40
+
41
+ test('Должна выбрасывать ошибку, если параметр не является массивом', () => {
42
+ expect(() => in_array('not an array', 1)).toThrow(TypeError);
43
+ expect(() => in_array('not an array', 1)).toThrow('Параметр "arr" должен быть массивом.');
44
+ });
45
+
46
+ test('Должна выбрасывать ошибку, если параметр strict не является логическим значением', () => {
47
+ expect(() => in_array([1, 2, 3], 1, 'not a boolean')).toThrow(TypeError);
48
+ expect(() => in_array([1, 2, 3], 1, 'not a boolean')).toThrow(
49
+ 'Параметр "strict" должен иметь логический тип.',
50
+ );
51
+ });
52
+ });
@@ -0,0 +1,71 @@
1
+ import { expect, test, describe } from '@jest/globals';
2
+ import { natsort } from '../../../index.mjs';
3
+
4
+ describe('Функция natsort', () => {
5
+ test('Должна корректно сортировать обычный массив', () => {
6
+ const array = [10, 2, 30, 4];
7
+ const result = natsort(array);
8
+ expect(result).toEqual([2, 4, 10, 30]);
9
+ });
10
+
11
+ test('Должна корректно сортировать ассоциативный массив', () => {
12
+ const array = { a: 10, b: 2, c: 30, d: 4 };
13
+ const result = natsort(array);
14
+ expect(result).toEqual([
15
+ ['b', 2],
16
+ ['d', 4],
17
+ ['a', 10],
18
+ ['c', 30],
19
+ ]);
20
+ });
21
+
22
+ test('Должна корректно сортировать массив с использованием функции getter', () => {
23
+ const array = [{ value: 10 }, { value: 2 }, { value: 30 }, { value: 4 }];
24
+ const result = natsort(array, (entry) => entry[1].value);
25
+ expect(result).toEqual([{ value: 2 }, { value: 4 }, { value: 10 }, { value: 30 }]);
26
+ });
27
+
28
+ test('Должна выбрасывать ошибку, если параметр getter не является функцией', () => {
29
+ const array = [10, 2, 30, 4];
30
+ expect(() => natsort(array, 'not a function')).toThrow(TypeError);
31
+ expect(() => natsort(array, 'not a function')).toThrow(
32
+ 'Параметр "getter" должен быть функцией.',
33
+ );
34
+ });
35
+
36
+ test('Должна корректно сортировать массив строк', () => {
37
+ const array = ['apple', 'banana', 'cherry', 'date'];
38
+ const result = natsort(array);
39
+ expect(result).toEqual(['apple', 'banana', 'cherry', 'date']);
40
+ });
41
+
42
+ test('Должна корректно сортировать массив строк с числовыми значениями', () => {
43
+ const array = ['10', '2', '30', '4'];
44
+ const result = natsort(array);
45
+ expect(result).toEqual(['2', '4', '10', '30']);
46
+ });
47
+
48
+ test('Должна корректно сортировать массив строк с ведущими нулями', () => {
49
+ const array = ['0010', '010', '10', '001'];
50
+ const result = natsort(array);
51
+ expect(result).toEqual(['001', '0010', '010', '10']);
52
+ });
53
+
54
+ test('Должна корректно сортировать массив строк с пробелами', () => {
55
+ const array = [' 10', '10', ' 2', '2'];
56
+ const result = natsort(array);
57
+ expect(result).toEqual([' 2', '2', ' 10', '10']);
58
+ });
59
+
60
+ test('Должна корректно сортировать массив строк с буквами и числами', () => {
61
+ const array = ['a10', 'a2', 'b10', 'b2'];
62
+ const result = natsort(array);
63
+ expect(result).toEqual(['a2', 'a10', 'b2', 'b10']);
64
+ });
65
+
66
+ test('Должна корректно сортировать массив строк с разными символами', () => {
67
+ const array = ['10-', '10+', '10*', '10/'];
68
+ const result = natsort(array);
69
+ expect(result).toEqual(['10*', '10+', '10-', '10/']);
70
+ });
71
+ });
@@ -0,0 +1,51 @@
1
+ import { expect, test, describe } from '@jest/globals';
2
+ import { range } from '../../../index.mjs';
3
+
4
+ describe('Функция range', () => {
5
+ test('Должна генерировать числовой диапазон', () => {
6
+ const result = range(1, 5);
7
+ expect(result).toEqual([1, 2, 3, 4, 5]);
8
+ });
9
+
10
+ test('Должна генерировать числовой диапазон с отрицательным шагом', () => {
11
+ const result = range(5, 1, -1);
12
+ expect(result).toEqual([5, 4, 3, 2, 1]);
13
+ });
14
+
15
+ test('Должна генерировать диапазон строк', () => {
16
+ const result = range('a', 'e');
17
+ expect(result).toEqual(['a', 'b', 'c', 'd', 'e']);
18
+ });
19
+
20
+ test('Должна обрабатывать значения с преобразованием типов', () => {
21
+ const result = range('1', 5);
22
+ expect(result).toEqual([1, 2, 3, 4, 5]);
23
+ });
24
+
25
+ test('Должна выбрасывать ошибку, если параметр "start" имеет неверный тип', () => {
26
+ expect(() => range({}, 5)).toThrow(TypeError);
27
+ expect(() => range({}, 5)).toThrow('Параметр "start" должен быть строкой или числом.');
28
+ });
29
+
30
+ test('Должна выбрасывать ошибку, если параметр "end" имеет неверный тип', () => {
31
+ expect(() => range(1, {})).toThrow(TypeError);
32
+ expect(() => range(1, {})).toThrow('Параметр "end" должен быть строкой или числом.');
33
+ });
34
+
35
+ test('Должна выбрасывать ошибку, если параметр "step" имеет неверный тип', () => {
36
+ expect(() => range(1, 5, 'a')).toThrow(TypeError);
37
+ expect(() => range(1, 5, 'a')).toThrow('Параметр "step" должен быть числом.');
38
+ });
39
+
40
+ test('Должна выбрасывать ошибку, если параметр "step" равен нулю', () => {
41
+ expect(() => range(1, 5, 0)).toThrow(TypeError);
42
+ expect(() => range(1, 5, 0)).toThrow('Параметр "step" не может быть равен нулю.');
43
+ });
44
+
45
+ test('Должна выбрасывать ошибку, если параметр "step" отрицательный при start < end', () => {
46
+ expect(() => range(1, 5, -1)).toThrow(TypeError);
47
+ expect(() => range(1, 5, -1)).toThrow(
48
+ 'Параметр "step" должен быть больше нуля при start <= end.',
49
+ );
50
+ });
51
+ });
@@ -0,0 +1,42 @@
1
+ import { expect, test, describe } from '@jest/globals';
2
+ import { shuffle } from '../../../index.mjs';
3
+
4
+ describe('Функция shuffle', () => {
5
+ test('Должна перемешивать элементы обычного массива', () => {
6
+ const array = [1, 2, 3, 4, 5];
7
+ const result = shuffle(array);
8
+ expect(result).toHaveLength(array.length);
9
+ expect(result).toEqual(expect.arrayContaining(array));
10
+ expect(result).not.toEqual(array); // Маловероятно, что массив останется в том же порядке
11
+ });
12
+
13
+ test('Должна перемешивать элементы ассоциативного массива', () => {
14
+ const array = { a: 1, b: 2, c: 3 };
15
+ const result = shuffle(array);
16
+ expect(result).toHaveLength(Object.keys(array).length);
17
+ expect(result).toEqual(
18
+ expect.arrayContaining([
19
+ ['a', 1],
20
+ ['b', 2],
21
+ ['c', 3],
22
+ ]),
23
+ );
24
+ });
25
+
26
+ test('Должна выбрасывать ошибку, если параметр не является массивом', () => {
27
+ expect(() => shuffle('not an array')).toThrow(TypeError);
28
+ expect(() => shuffle('not an array')).toThrow('Параметр "arr" должен быть массивом.');
29
+ });
30
+
31
+ test('Должна возвращать пустой массив, если исходный массив пуст', () => {
32
+ const array = [];
33
+ const result = shuffle(array);
34
+ expect(result).toEqual([]);
35
+ });
36
+
37
+ test('Должна корректно перемешивать массив с одним элементом', () => {
38
+ const array = [1];
39
+ const result = shuffle(array);
40
+ expect(result).toEqual([1]);
41
+ });
42
+ });
@@ -0,0 +1,60 @@
1
+ import { expect, test, describe } from '@jest/globals';
2
+ import { sort } from '../../../index.mjs';
3
+
4
+ describe('Функция sort', () => {
5
+ test('Должна сортировать элементы обычного массива по умолчанию', () => {
6
+ const array = [5, 3, 1, 4, 2];
7
+ const result = sort(array);
8
+ expect(result).toEqual([1, 2, 3, 4, 5]);
9
+ });
10
+
11
+ test('Должна сортировать элементы ассоциативного массива по умолчанию', () => {
12
+ const array = { a: 3, b: 1, c: 2 };
13
+ const result = sort(array);
14
+ expect(result).toEqual([
15
+ ['b', 1],
16
+ ['c', 2],
17
+ ['a', 3],
18
+ ]);
19
+ });
20
+
21
+ test('Должна сортировать элементы обычного массива с использованием пользовательской функции сравнения', () => {
22
+ const array = [5, 3, 1, 4, 2];
23
+ const result = sort(array, (a, b) => b[1] - a[1]);
24
+ expect(result).toEqual([5, 4, 3, 2, 1]);
25
+ });
26
+
27
+ test('Должна сортировать элементы ассоциативного массива с использованием пользовательской функции сравнения', () => {
28
+ const array = { a: 3, b: 1, c: 2 };
29
+ const result = sort(array, (a, b) => b[1] - a[1]);
30
+ expect(result).toEqual([
31
+ ['a', 3],
32
+ ['c', 2],
33
+ ['b', 1],
34
+ ]);
35
+ });
36
+
37
+ test('Должна выбрасывать ошибку, если параметр не является массивом', () => {
38
+ expect(() => sort('not an array')).toThrow(TypeError);
39
+ expect(() => sort('not an array')).toThrow('Параметр "arr" должен быть массивом.');
40
+ });
41
+
42
+ test('Должна выбрасывать ошибку, если параметр compare_func не является функцией', () => {
43
+ expect(() => sort([1, 2, 3], 'not a function')).toThrow(TypeError);
44
+ expect(() => sort([1, 2, 3], 'not a function')).toThrow(
45
+ 'Параметр "compare_func" должен быть функцией.',
46
+ );
47
+ });
48
+
49
+ test('Должна корректно сортировать пустой массив', () => {
50
+ const array = [];
51
+ const result = sort(array);
52
+ expect(result).toEqual([]);
53
+ });
54
+
55
+ test('Должна корректно сортировать массив с одним элементом', () => {
56
+ const array = [1];
57
+ const result = sort(array);
58
+ expect(result).toEqual([1]);
59
+ });
60
+ });