@haskou/value-objects 1.1.0 → 1.1.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.
Files changed (464) hide show
  1. package/dist/src/errors/BaseError.d.ts +8 -0
  2. package/dist/src/errors/BaseError.d.ts.map +1 -0
  3. package/dist/src/errors/BaseError.js +22 -0
  4. package/dist/src/errors/BaseError.js.map +1 -0
  5. package/dist/src/errors/DomainError.d.ts +7 -0
  6. package/dist/src/errors/DomainError.d.ts.map +1 -0
  7. package/dist/src/errors/DomainError.js +15 -0
  8. package/dist/src/errors/DomainError.js.map +1 -0
  9. package/dist/src/errors/InvalidColorError.d.ts +5 -0
  10. package/dist/src/errors/InvalidColorError.d.ts.map +1 -0
  11. package/dist/src/errors/InvalidColorError.js +11 -0
  12. package/dist/src/errors/InvalidColorError.js.map +1 -0
  13. package/dist/src/errors/InvalidDayError.d.ts +5 -0
  14. package/dist/src/errors/InvalidDayError.d.ts.map +1 -0
  15. package/dist/src/errors/InvalidDayError.js +11 -0
  16. package/dist/src/errors/InvalidDayError.js.map +1 -0
  17. package/dist/src/errors/InvalidDayFormatError.d.ts +5 -0
  18. package/dist/src/errors/InvalidDayFormatError.d.ts.map +1 -0
  19. package/dist/src/errors/InvalidDayFormatError.js +11 -0
  20. package/dist/src/errors/InvalidDayFormatError.js.map +1 -0
  21. package/dist/src/errors/InvalidEmailError.d.ts +5 -0
  22. package/dist/src/errors/InvalidEmailError.d.ts.map +1 -0
  23. package/dist/src/errors/InvalidEmailError.js +11 -0
  24. package/dist/src/errors/InvalidEmailError.js.map +1 -0
  25. package/dist/src/errors/InvalidFormatError.d.ts +5 -0
  26. package/dist/src/errors/InvalidFormatError.d.ts.map +1 -0
  27. package/dist/src/errors/InvalidFormatError.js +11 -0
  28. package/dist/src/errors/InvalidFormatError.js.map +1 -0
  29. package/dist/src/errors/InvalidHashError.d.ts +5 -0
  30. package/dist/src/errors/InvalidHashError.d.ts.map +1 -0
  31. package/dist/src/errors/InvalidHashError.js +11 -0
  32. package/dist/src/errors/InvalidHashError.js.map +1 -0
  33. package/dist/src/errors/InvalidHourError.d.ts +5 -0
  34. package/dist/src/errors/InvalidHourError.d.ts.map +1 -0
  35. package/dist/src/errors/InvalidHourError.js +11 -0
  36. package/dist/src/errors/InvalidHourError.js.map +1 -0
  37. package/dist/src/errors/InvalidIntegerError.d.ts +5 -0
  38. package/dist/src/errors/InvalidIntegerError.d.ts.map +1 -0
  39. package/dist/src/errors/InvalidIntegerError.js +11 -0
  40. package/dist/src/errors/InvalidIntegerError.js.map +1 -0
  41. package/dist/src/errors/InvalidLatitudeError.d.ts +5 -0
  42. package/dist/src/errors/InvalidLatitudeError.d.ts.map +1 -0
  43. package/dist/src/errors/InvalidLatitudeError.js +11 -0
  44. package/dist/src/errors/InvalidLatitudeError.js.map +1 -0
  45. package/dist/src/errors/InvalidLengthError.d.ts +5 -0
  46. package/dist/src/errors/InvalidLengthError.d.ts.map +1 -0
  47. package/dist/src/errors/InvalidLengthError.js +11 -0
  48. package/dist/src/errors/InvalidLengthError.js.map +1 -0
  49. package/dist/src/errors/InvalidLongitudeError.d.ts +5 -0
  50. package/dist/src/errors/InvalidLongitudeError.d.ts.map +1 -0
  51. package/dist/src/errors/InvalidLongitudeError.js +11 -0
  52. package/dist/src/errors/InvalidLongitudeError.js.map +1 -0
  53. package/dist/src/errors/InvalidMinutesError.d.ts +5 -0
  54. package/dist/src/errors/InvalidMinutesError.d.ts.map +1 -0
  55. package/dist/src/errors/InvalidMinutesError.js +11 -0
  56. package/dist/src/errors/InvalidMinutesError.js.map +1 -0
  57. package/dist/src/errors/InvalidNumberError.d.ts +5 -0
  58. package/dist/src/errors/InvalidNumberError.d.ts.map +1 -0
  59. package/dist/src/errors/InvalidNumberError.js +11 -0
  60. package/dist/src/errors/InvalidNumberError.js.map +1 -0
  61. package/dist/src/errors/InvalidPositiveNumberError.d.ts +5 -0
  62. package/dist/src/errors/InvalidPositiveNumberError.d.ts.map +1 -0
  63. package/dist/src/errors/InvalidPositiveNumberError.js +11 -0
  64. package/dist/src/errors/InvalidPositiveNumberError.js.map +1 -0
  65. package/dist/src/errors/InvalidStringLengthError.d.ts +5 -0
  66. package/dist/src/errors/InvalidStringLengthError.d.ts.map +1 -0
  67. package/dist/src/errors/InvalidStringLengthError.js +11 -0
  68. package/dist/src/errors/InvalidStringLengthError.js.map +1 -0
  69. package/dist/src/errors/InvalidTimestampIntervalError.d.ts +6 -0
  70. package/dist/src/errors/InvalidTimestampIntervalError.d.ts.map +1 -0
  71. package/dist/src/errors/InvalidTimestampIntervalError.js +11 -0
  72. package/dist/src/errors/InvalidTimestampIntervalError.js.map +1 -0
  73. package/dist/src/errors/InvalidValueError.d.ts +5 -0
  74. package/dist/src/errors/InvalidValueError.d.ts.map +1 -0
  75. package/dist/src/errors/InvalidValueError.js +11 -0
  76. package/dist/src/errors/InvalidValueError.js.map +1 -0
  77. package/dist/src/errors/NullObjectError.d.ts +5 -0
  78. package/dist/src/errors/NullObjectError.d.ts.map +1 -0
  79. package/dist/src/errors/NullObjectError.js +12 -0
  80. package/dist/src/errors/NullObjectError.js.map +1 -0
  81. package/dist/src/errors/ValueNotInEnumError.d.ts +5 -0
  82. package/dist/src/errors/ValueNotInEnumError.d.ts.map +1 -0
  83. package/dist/src/errors/ValueNotInEnumError.js +11 -0
  84. package/dist/src/errors/ValueNotInEnumError.js.map +1 -0
  85. package/{src/errors/index.ts → dist/src/errors/index.d.ts} +1 -0
  86. package/dist/src/errors/index.d.ts.map +1 -0
  87. package/dist/src/errors/index.js +24 -0
  88. package/dist/src/errors/index.js.map +1 -0
  89. package/{src/index.ts → dist/src/index.d.ts} +1 -0
  90. package/dist/src/index.d.ts.map +1 -0
  91. package/dist/src/index.js +9 -0
  92. package/dist/src/index.js.map +1 -0
  93. package/dist/src/interfaces/PrimitiveOf.d.ts +5 -0
  94. package/dist/src/interfaces/PrimitiveOf.d.ts.map +1 -0
  95. package/dist/src/interfaces/PrimitiveOf.js +3 -0
  96. package/dist/src/interfaces/PrimitiveOf.js.map +1 -0
  97. package/dist/src/interfaces/index.d.ts +2 -0
  98. package/dist/src/interfaces/index.d.ts.map +1 -0
  99. package/dist/src/interfaces/index.js +5 -0
  100. package/dist/src/interfaces/index.js.map +1 -0
  101. package/dist/src/patterns/Assert.d.ts +5 -0
  102. package/dist/src/patterns/Assert.d.ts.map +1 -0
  103. package/dist/src/patterns/Assert.js +11 -0
  104. package/dist/src/patterns/Assert.js.map +1 -0
  105. package/dist/src/patterns/index.d.ts +2 -0
  106. package/dist/src/patterns/index.d.ts.map +1 -0
  107. package/dist/src/patterns/index.js +5 -0
  108. package/dist/src/patterns/index.js.map +1 -0
  109. package/{src/types/Nullish.ts → dist/src/types/Nullish.d.ts} +1 -0
  110. package/dist/src/types/Nullish.d.ts.map +1 -0
  111. package/dist/src/types/Nullish.js +3 -0
  112. package/dist/src/types/Nullish.js.map +1 -0
  113. package/{src/types/Primitive.ts → dist/src/types/Primitive.d.ts} +1 -0
  114. package/dist/src/types/Primitive.d.ts.map +1 -0
  115. package/dist/src/types/Primitive.js +3 -0
  116. package/dist/src/types/Primitive.js.map +1 -0
  117. package/{src/types/index.ts → dist/src/types/index.d.ts} +1 -0
  118. package/dist/src/types/index.d.ts.map +1 -0
  119. package/dist/src/types/index.js +6 -0
  120. package/dist/src/types/index.js.map +1 -0
  121. package/dist/src/value-objects/Color.d.ts +19 -0
  122. package/dist/src/value-objects/Color.d.ts.map +1 -0
  123. package/dist/src/value-objects/Color.js +37 -0
  124. package/dist/src/value-objects/Color.js.map +1 -0
  125. package/dist/src/value-objects/Email.d.ts +6 -0
  126. package/dist/src/value-objects/Email.d.ts.map +1 -0
  127. package/dist/src/value-objects/Email.js +21 -0
  128. package/dist/src/value-objects/Email.js.map +1 -0
  129. package/dist/src/value-objects/Enum.d.ts +9 -0
  130. package/dist/src/value-objects/Enum.d.ts.map +1 -0
  131. package/dist/src/value-objects/Enum.js +24 -0
  132. package/dist/src/value-objects/Enum.js.map +1 -0
  133. package/dist/src/value-objects/Integer.d.ts +6 -0
  134. package/dist/src/value-objects/Integer.d.ts.map +1 -0
  135. package/dist/src/value-objects/Integer.js +21 -0
  136. package/dist/src/value-objects/Integer.js.map +1 -0
  137. package/dist/src/value-objects/NullObject.d.ts +8 -0
  138. package/dist/src/value-objects/NullObject.d.ts.map +1 -0
  139. package/dist/src/value-objects/NullObject.js +43 -0
  140. package/dist/src/value-objects/NullObject.js.map +1 -0
  141. package/dist/src/value-objects/NumberValueObject.d.ts +15 -0
  142. package/dist/src/value-objects/NumberValueObject.d.ts.map +1 -0
  143. package/dist/src/value-objects/NumberValueObject.js +48 -0
  144. package/dist/src/value-objects/NumberValueObject.js.map +1 -0
  145. package/dist/src/value-objects/PositiveNumber.d.ts +6 -0
  146. package/dist/src/value-objects/PositiveNumber.d.ts.map +1 -0
  147. package/dist/src/value-objects/PositiveNumber.js +21 -0
  148. package/dist/src/value-objects/PositiveNumber.js.map +1 -0
  149. package/dist/src/value-objects/StringValueObject.d.ts +7 -0
  150. package/dist/src/value-objects/StringValueObject.d.ts.map +1 -0
  151. package/dist/src/value-objects/StringValueObject.js +24 -0
  152. package/dist/src/value-objects/StringValueObject.js.map +1 -0
  153. package/dist/src/value-objects/ValueObject.d.ts +12 -0
  154. package/dist/src/value-objects/ValueObject.d.ts.map +1 -0
  155. package/dist/src/value-objects/ValueObject.js +33 -0
  156. package/dist/src/value-objects/ValueObject.js.map +1 -0
  157. package/dist/src/value-objects/coordinates/Coordinates.d.ts +12 -0
  158. package/dist/src/value-objects/coordinates/Coordinates.d.ts.map +1 -0
  159. package/dist/src/value-objects/coordinates/Coordinates.js +28 -0
  160. package/dist/src/value-objects/coordinates/Coordinates.js.map +1 -0
  161. package/dist/src/value-objects/coordinates/Latitude.d.ts +8 -0
  162. package/dist/src/value-objects/coordinates/Latitude.d.ts.map +1 -0
  163. package/dist/src/value-objects/coordinates/Latitude.js +21 -0
  164. package/dist/src/value-objects/coordinates/Latitude.js.map +1 -0
  165. package/dist/src/value-objects/coordinates/Longitude.d.ts +8 -0
  166. package/dist/src/value-objects/coordinates/Longitude.d.ts.map +1 -0
  167. package/dist/src/value-objects/coordinates/Longitude.js +21 -0
  168. package/dist/src/value-objects/coordinates/Longitude.js.map +1 -0
  169. package/{src/value-objects/coordinates/index.ts → dist/src/value-objects/coordinates/index.d.ts} +1 -0
  170. package/dist/src/value-objects/coordinates/index.d.ts.map +1 -0
  171. package/dist/src/value-objects/coordinates/index.js +7 -0
  172. package/dist/src/value-objects/coordinates/index.js.map +1 -0
  173. package/dist/src/value-objects/hashes/Hash.d.ts +7 -0
  174. package/dist/src/value-objects/hashes/Hash.d.ts.map +1 -0
  175. package/dist/src/value-objects/hashes/Hash.js +19 -0
  176. package/dist/src/value-objects/hashes/Hash.js.map +1 -0
  177. package/dist/src/value-objects/hashes/MD5Hash.d.ts +8 -0
  178. package/dist/src/value-objects/hashes/MD5Hash.d.ts.map +1 -0
  179. package/dist/src/value-objects/hashes/MD5Hash.js +26 -0
  180. package/dist/src/value-objects/hashes/MD5Hash.js.map +1 -0
  181. package/dist/src/value-objects/hashes/SHA256Hash.d.ts +9 -0
  182. package/dist/src/value-objects/hashes/SHA256Hash.d.ts.map +1 -0
  183. package/dist/src/value-objects/hashes/SHA256Hash.js +29 -0
  184. package/dist/src/value-objects/hashes/SHA256Hash.js.map +1 -0
  185. package/dist/src/value-objects/hashes/SHA512Hash.d.ts +9 -0
  186. package/dist/src/value-objects/hashes/SHA512Hash.d.ts.map +1 -0
  187. package/dist/src/value-objects/hashes/SHA512Hash.js +29 -0
  188. package/dist/src/value-objects/hashes/SHA512Hash.js.map +1 -0
  189. package/{src/value-objects/hashes/index.ts → dist/src/value-objects/hashes/index.d.ts} +1 -0
  190. package/dist/src/value-objects/hashes/index.d.ts.map +1 -0
  191. package/dist/src/value-objects/hashes/index.js +8 -0
  192. package/dist/src/value-objects/hashes/index.js.map +1 -0
  193. package/dist/src/value-objects/ids/ShortId.d.ts +10 -0
  194. package/dist/src/value-objects/ids/ShortId.d.ts.map +1 -0
  195. package/dist/src/value-objects/ids/ShortId.js +30 -0
  196. package/dist/src/value-objects/ids/ShortId.js.map +1 -0
  197. package/dist/src/value-objects/ids/UUID.d.ts +10 -0
  198. package/dist/src/value-objects/ids/UUID.d.ts.map +1 -0
  199. package/dist/src/value-objects/ids/UUID.js +29 -0
  200. package/dist/src/value-objects/ids/UUID.js.map +1 -0
  201. package/dist/src/value-objects/ids/index.d.ts +3 -0
  202. package/dist/src/value-objects/ids/index.d.ts.map +1 -0
  203. package/dist/src/value-objects/ids/index.js +6 -0
  204. package/dist/src/value-objects/ids/index.js.map +1 -0
  205. package/{src/value-objects/index.ts → dist/src/value-objects/index.d.ts} +2 -0
  206. package/dist/src/value-objects/index.d.ts.map +1 -0
  207. package/dist/src/value-objects/index.js +16 -0
  208. package/dist/src/value-objects/index.js.map +1 -0
  209. package/dist/src/value-objects/time/CalendarDay.d.ts +25 -0
  210. package/dist/src/value-objects/time/CalendarDay.d.ts.map +1 -0
  211. package/dist/src/value-objects/time/CalendarDay.js +74 -0
  212. package/dist/src/value-objects/time/CalendarDay.js.map +1 -0
  213. package/dist/src/value-objects/time/Day.d.ts +7 -0
  214. package/dist/src/value-objects/time/Day.d.ts.map +1 -0
  215. package/dist/src/value-objects/time/Day.js +18 -0
  216. package/dist/src/value-objects/time/Day.js.map +1 -0
  217. package/dist/src/value-objects/time/DayOfWeek.d.ts +34 -0
  218. package/dist/src/value-objects/time/DayOfWeek.d.ts.map +1 -0
  219. package/dist/src/value-objects/time/DayOfWeek.js +52 -0
  220. package/dist/src/value-objects/time/DayOfWeek.js.map +1 -0
  221. package/dist/src/value-objects/time/Duration.d.ts +23 -0
  222. package/dist/src/value-objects/time/Duration.d.ts.map +1 -0
  223. package/dist/src/value-objects/time/Duration.js +79 -0
  224. package/dist/src/value-objects/time/Duration.js.map +1 -0
  225. package/dist/src/value-objects/time/Hour.d.ts +15 -0
  226. package/dist/src/value-objects/time/Hour.d.ts.map +1 -0
  227. package/dist/src/value-objects/time/Hour.js +81 -0
  228. package/dist/src/value-objects/time/Hour.js.map +1 -0
  229. package/dist/src/value-objects/time/Month.d.ts +18 -0
  230. package/dist/src/value-objects/time/Month.d.ts.map +1 -0
  231. package/dist/src/value-objects/time/Month.js +41 -0
  232. package/dist/src/value-objects/time/Month.js.map +1 -0
  233. package/dist/src/value-objects/time/MonthOfYear.d.ts +17 -0
  234. package/dist/src/value-objects/time/MonthOfYear.d.ts.map +1 -0
  235. package/dist/src/value-objects/time/MonthOfYear.js +45 -0
  236. package/dist/src/value-objects/time/MonthOfYear.js.map +1 -0
  237. package/dist/src/value-objects/time/Timestamp.d.ts +51 -0
  238. package/dist/src/value-objects/time/Timestamp.d.ts.map +1 -0
  239. package/dist/src/value-objects/time/Timestamp.js +156 -0
  240. package/dist/src/value-objects/time/Timestamp.js.map +1 -0
  241. package/dist/src/value-objects/time/TimestampInterval.d.ts +26 -0
  242. package/dist/src/value-objects/time/TimestampInterval.d.ts.map +1 -0
  243. package/dist/src/value-objects/time/TimestampInterval.js +88 -0
  244. package/dist/src/value-objects/time/TimestampInterval.js.map +1 -0
  245. package/dist/src/value-objects/time/Year.d.ts +10 -0
  246. package/dist/src/value-objects/time/Year.d.ts.map +1 -0
  247. package/dist/src/value-objects/time/Year.js +26 -0
  248. package/dist/src/value-objects/time/Year.js.map +1 -0
  249. package/{src/value-objects/time/index.ts → dist/src/value-objects/time/index.d.ts} +1 -0
  250. package/dist/src/value-objects/time/index.d.ts.map +1 -0
  251. package/dist/src/value-objects/time/index.js +14 -0
  252. package/dist/src/value-objects/time/index.js.map +1 -0
  253. package/dist/tests/errors/BaseError.spec.d.ts +2 -0
  254. package/dist/tests/errors/BaseError.spec.d.ts.map +1 -0
  255. package/dist/tests/errors/BaseError.spec.js +54 -0
  256. package/dist/tests/errors/BaseError.spec.js.map +1 -0
  257. package/dist/tests/errors/DomainError.spec.d.ts +2 -0
  258. package/dist/tests/errors/DomainError.spec.d.ts.map +1 -0
  259. package/dist/tests/errors/DomainError.spec.js +47 -0
  260. package/dist/tests/errors/DomainError.spec.js.map +1 -0
  261. package/dist/tests/patterns/Assert.spec.d.ts +2 -0
  262. package/dist/tests/patterns/Assert.spec.d.ts.map +1 -0
  263. package/dist/tests/patterns/Assert.spec.js +27 -0
  264. package/dist/tests/patterns/Assert.spec.js.map +1 -0
  265. package/dist/tests/setup.jest.d.ts +2 -0
  266. package/dist/tests/setup.jest.d.ts.map +1 -0
  267. package/dist/tests/setup.jest.js +6 -0
  268. package/dist/tests/setup.jest.js.map +1 -0
  269. package/dist/tests/value-objects/Color.spec.d.ts +2 -0
  270. package/dist/tests/value-objects/Color.spec.d.ts.map +1 -0
  271. package/dist/tests/value-objects/Color.spec.js +171 -0
  272. package/dist/tests/value-objects/Color.spec.js.map +1 -0
  273. package/dist/tests/value-objects/Email.spec.d.ts +2 -0
  274. package/dist/tests/value-objects/Email.spec.d.ts.map +1 -0
  275. package/dist/tests/value-objects/Email.spec.js +117 -0
  276. package/dist/tests/value-objects/Email.spec.js.map +1 -0
  277. package/dist/tests/value-objects/Enum.spec.d.ts +2 -0
  278. package/dist/tests/value-objects/Enum.spec.d.ts.map +1 -0
  279. package/dist/tests/value-objects/Enum.spec.js +233 -0
  280. package/dist/tests/value-objects/Enum.spec.js.map +1 -0
  281. package/dist/tests/value-objects/Integer.spec.d.ts +2 -0
  282. package/dist/tests/value-objects/Integer.spec.d.ts.map +1 -0
  283. package/dist/tests/value-objects/Integer.spec.js +31 -0
  284. package/dist/tests/value-objects/Integer.spec.js.map +1 -0
  285. package/dist/tests/value-objects/NullObject.spec.d.ts +2 -0
  286. package/dist/tests/value-objects/NullObject.spec.d.ts.map +1 -0
  287. package/dist/tests/value-objects/NullObject.spec.js +48 -0
  288. package/dist/tests/value-objects/NullObject.spec.js.map +1 -0
  289. package/dist/tests/value-objects/NumberValueObject.spec.d.ts +2 -0
  290. package/dist/tests/value-objects/NumberValueObject.spec.d.ts.map +1 -0
  291. package/dist/tests/value-objects/NumberValueObject.spec.js +333 -0
  292. package/dist/tests/value-objects/NumberValueObject.spec.js.map +1 -0
  293. package/dist/tests/value-objects/PositiveNumber.spec.d.ts +2 -0
  294. package/dist/tests/value-objects/PositiveNumber.spec.d.ts.map +1 -0
  295. package/dist/tests/value-objects/PositiveNumber.spec.js +209 -0
  296. package/dist/tests/value-objects/PositiveNumber.spec.js.map +1 -0
  297. package/dist/tests/value-objects/StringValueObject.spec.d.ts +2 -0
  298. package/dist/tests/value-objects/StringValueObject.spec.d.ts.map +1 -0
  299. package/dist/tests/value-objects/StringValueObject.spec.js +104 -0
  300. package/dist/tests/value-objects/StringValueObject.spec.js.map +1 -0
  301. package/dist/tests/value-objects/coordinates/Coordinates.spec.d.ts +2 -0
  302. package/dist/tests/value-objects/coordinates/Coordinates.spec.d.ts.map +1 -0
  303. package/dist/tests/value-objects/coordinates/Coordinates.spec.js +76 -0
  304. package/dist/tests/value-objects/coordinates/Coordinates.spec.js.map +1 -0
  305. package/dist/tests/value-objects/coordinates/Latitude.spec.d.ts +2 -0
  306. package/dist/tests/value-objects/coordinates/Latitude.spec.d.ts.map +1 -0
  307. package/dist/tests/value-objects/coordinates/Latitude.spec.js +23 -0
  308. package/dist/tests/value-objects/coordinates/Latitude.spec.js.map +1 -0
  309. package/dist/tests/value-objects/coordinates/Longitude.spec.d.ts +2 -0
  310. package/dist/tests/value-objects/coordinates/Longitude.spec.d.ts.map +1 -0
  311. package/dist/tests/value-objects/coordinates/Longitude.spec.js +23 -0
  312. package/dist/tests/value-objects/coordinates/Longitude.spec.js.map +1 -0
  313. package/dist/tests/value-objects/hashes/Hashes.spec.d.ts +2 -0
  314. package/dist/tests/value-objects/hashes/Hashes.spec.d.ts.map +1 -0
  315. package/dist/tests/value-objects/hashes/Hashes.spec.js +107 -0
  316. package/dist/tests/value-objects/hashes/Hashes.spec.js.map +1 -0
  317. package/dist/tests/value-objects/hashes/MD5Hash.spec.d.ts +2 -0
  318. package/dist/tests/value-objects/hashes/MD5Hash.spec.d.ts.map +1 -0
  319. package/dist/tests/value-objects/hashes/MD5Hash.spec.js +147 -0
  320. package/dist/tests/value-objects/hashes/MD5Hash.spec.js.map +1 -0
  321. package/dist/tests/value-objects/hashes/SHA256Hash.spec.d.ts +2 -0
  322. package/dist/tests/value-objects/hashes/SHA256Hash.spec.d.ts.map +1 -0
  323. package/dist/tests/value-objects/hashes/SHA256Hash.spec.js +147 -0
  324. package/dist/tests/value-objects/hashes/SHA256Hash.spec.js.map +1 -0
  325. package/dist/tests/value-objects/hashes/SHA512Hash.spec.d.ts +2 -0
  326. package/dist/tests/value-objects/hashes/SHA512Hash.spec.d.ts.map +1 -0
  327. package/dist/tests/value-objects/hashes/SHA512Hash.spec.js +147 -0
  328. package/dist/tests/value-objects/hashes/SHA512Hash.spec.js.map +1 -0
  329. package/dist/tests/value-objects/ids/ShortId.spec.d.ts +2 -0
  330. package/dist/tests/value-objects/ids/ShortId.spec.d.ts.map +1 -0
  331. package/dist/tests/value-objects/ids/ShortId.spec.js +30 -0
  332. package/dist/tests/value-objects/ids/ShortId.spec.js.map +1 -0
  333. package/dist/tests/value-objects/ids/UUID.spec.d.ts +2 -0
  334. package/dist/tests/value-objects/ids/UUID.spec.d.ts.map +1 -0
  335. package/dist/tests/value-objects/ids/UUID.spec.js +30 -0
  336. package/dist/tests/value-objects/ids/UUID.spec.js.map +1 -0
  337. package/dist/tests/value-objects/time/CalendarDay.spec.d.ts +2 -0
  338. package/dist/tests/value-objects/time/CalendarDay.spec.d.ts.map +1 -0
  339. package/dist/tests/value-objects/time/CalendarDay.spec.js +149 -0
  340. package/dist/tests/value-objects/time/CalendarDay.spec.js.map +1 -0
  341. package/dist/tests/value-objects/time/Day.spec.d.ts +2 -0
  342. package/dist/tests/value-objects/time/Day.spec.d.ts.map +1 -0
  343. package/dist/tests/value-objects/time/Day.spec.js +28 -0
  344. package/dist/tests/value-objects/time/Day.spec.js.map +1 -0
  345. package/dist/tests/value-objects/time/DayOfWeek.spec.d.ts +2 -0
  346. package/dist/tests/value-objects/time/DayOfWeek.spec.d.ts.map +1 -0
  347. package/dist/tests/value-objects/time/DayOfWeek.spec.js +44 -0
  348. package/dist/tests/value-objects/time/DayOfWeek.spec.js.map +1 -0
  349. package/dist/tests/value-objects/time/Duration.spec.d.ts +2 -0
  350. package/dist/tests/value-objects/time/Duration.spec.d.ts.map +1 -0
  351. package/dist/tests/value-objects/time/Duration.spec.js +255 -0
  352. package/dist/tests/value-objects/time/Duration.spec.js.map +1 -0
  353. package/dist/tests/value-objects/time/Hour.spec.d.ts +2 -0
  354. package/dist/tests/value-objects/time/Hour.spec.d.ts.map +1 -0
  355. package/dist/tests/value-objects/time/Hour.spec.js +168 -0
  356. package/dist/tests/value-objects/time/Hour.spec.js.map +1 -0
  357. package/dist/tests/value-objects/time/MonthOfYear.spec.d.ts +2 -0
  358. package/dist/tests/value-objects/time/MonthOfYear.spec.d.ts.map +1 -0
  359. package/dist/tests/value-objects/time/MonthOfYear.spec.js +93 -0
  360. package/dist/tests/value-objects/time/MonthOfYear.spec.js.map +1 -0
  361. package/dist/tests/value-objects/time/Timestamp.spec.d.ts +2 -0
  362. package/dist/tests/value-objects/time/Timestamp.spec.d.ts.map +1 -0
  363. package/dist/tests/value-objects/time/Timestamp.spec.js +391 -0
  364. package/dist/tests/value-objects/time/Timestamp.spec.js.map +1 -0
  365. package/dist/tests/value-objects/time/TimestampInterval.spec.d.ts +2 -0
  366. package/dist/tests/value-objects/time/TimestampInterval.spec.d.ts.map +1 -0
  367. package/dist/tests/value-objects/time/TimestampInterval.spec.js +270 -0
  368. package/dist/tests/value-objects/time/TimestampInterval.spec.js.map +1 -0
  369. package/dist/tests/value-objects/time/Year.spec.d.ts +2 -0
  370. package/dist/tests/value-objects/time/Year.spec.d.ts.map +1 -0
  371. package/dist/tests/value-objects/time/Year.spec.js +41 -0
  372. package/dist/tests/value-objects/time/Year.spec.js.map +1 -0
  373. package/package.json +6 -2
  374. package/.editorconfig +0 -15
  375. package/.eslintignore +0 -3
  376. package/.eslintrc.json +0 -218
  377. package/.prettierrc.json +0 -13
  378. package/TECHNICAL_DOCUMENTATION.md +0 -1257
  379. package/jest.config.ts +0 -30
  380. package/src/errors/BaseError.ts +0 -20
  381. package/src/errors/DomainError.ts +0 -12
  382. package/src/errors/InvalidColorError.ts +0 -7
  383. package/src/errors/InvalidDayError.ts +0 -7
  384. package/src/errors/InvalidDayFormatError.ts +0 -7
  385. package/src/errors/InvalidEmailError.ts +0 -7
  386. package/src/errors/InvalidFormatError.ts +0 -7
  387. package/src/errors/InvalidHashError.ts +0 -7
  388. package/src/errors/InvalidHourError.ts +0 -7
  389. package/src/errors/InvalidIntegerError.ts +0 -7
  390. package/src/errors/InvalidLatitudeError.ts +0 -7
  391. package/src/errors/InvalidLengthError.ts +0 -9
  392. package/src/errors/InvalidLongitudeError.ts +0 -7
  393. package/src/errors/InvalidMinutesError.ts +0 -7
  394. package/src/errors/InvalidNumberError.ts +0 -7
  395. package/src/errors/InvalidPositiveNumberError.ts +0 -7
  396. package/src/errors/InvalidStringLengthError.ts +0 -9
  397. package/src/errors/InvalidTimestampIntervalError.ts +0 -10
  398. package/src/errors/InvalidValueError.ts +0 -7
  399. package/src/errors/NullObjectError.ts +0 -8
  400. package/src/errors/ValueNotInEnumError.ts +0 -9
  401. package/src/interfaces/PrimitiveOf.ts +0 -5
  402. package/src/interfaces/index.ts +0 -1
  403. package/src/patterns/Assert.ts +0 -15
  404. package/src/patterns/index.ts +0 -1
  405. package/src/value-objects/Color.ts +0 -39
  406. package/src/value-objects/Email.ts +0 -23
  407. package/src/value-objects/Enum.ts +0 -31
  408. package/src/value-objects/Integer.ts +0 -22
  409. package/src/value-objects/NullObject.ts +0 -60
  410. package/src/value-objects/NumberValueObject.ts +0 -56
  411. package/src/value-objects/PositiveNumber.ts +0 -20
  412. package/src/value-objects/StringValueObject.ts +0 -27
  413. package/src/value-objects/ValueObject.ts +0 -39
  414. package/src/value-objects/coordinates/Coordinates.ts +0 -30
  415. package/src/value-objects/coordinates/Latitude.ts +0 -22
  416. package/src/value-objects/coordinates/Longitude.ts +0 -25
  417. package/src/value-objects/hashes/Hash.ts +0 -19
  418. package/src/value-objects/hashes/MD5Hash.ts +0 -32
  419. package/src/value-objects/hashes/SHA256Hash.ts +0 -38
  420. package/src/value-objects/hashes/SHA512Hash.ts +0 -38
  421. package/src/value-objects/ids/ShortId.ts +0 -34
  422. package/src/value-objects/ids/UUID.ts +0 -34
  423. package/src/value-objects/time/CalendarDay.ts +0 -91
  424. package/src/value-objects/time/Day.ts +0 -17
  425. package/src/value-objects/time/DayOfWeek.ts +0 -60
  426. package/src/value-objects/time/Duration.ts +0 -142
  427. package/src/value-objects/time/Hour.ts +0 -105
  428. package/src/value-objects/time/Month.ts +0 -39
  429. package/src/value-objects/time/MonthOfYear.ts +0 -52
  430. package/src/value-objects/time/Timestamp.ts +0 -208
  431. package/src/value-objects/time/TimestampInterval.ts +0 -122
  432. package/src/value-objects/time/Year.ts +0 -27
  433. package/tests/errors/BaseError.spec.ts +0 -63
  434. package/tests/errors/DomainError.spec.ts +0 -52
  435. package/tests/patterns/Assert.spec.ts +0 -29
  436. package/tests/setup.jest.ts +0 -2
  437. package/tests/value-objects/Color.spec.ts +0 -214
  438. package/tests/value-objects/Email.spec.ts +0 -141
  439. package/tests/value-objects/Enum.spec.ts +0 -293
  440. package/tests/value-objects/Integer.spec.ts +0 -38
  441. package/tests/value-objects/NullObject.spec.ts +0 -55
  442. package/tests/value-objects/NumberValueObject.spec.ts +0 -446
  443. package/tests/value-objects/PositiveNumber.spec.ts +0 -274
  444. package/tests/value-objects/StringValueObject.spec.ts +0 -135
  445. package/tests/value-objects/coordinates/Coordinates.spec.ts +0 -90
  446. package/tests/value-objects/coordinates/Latitude.spec.ts +0 -24
  447. package/tests/value-objects/coordinates/Longitude.spec.ts +0 -24
  448. package/tests/value-objects/hashes/Hashes.spec.ts +0 -139
  449. package/tests/value-objects/hashes/MD5Hash.spec.ts +0 -187
  450. package/tests/value-objects/hashes/SHA256Hash.spec.ts +0 -220
  451. package/tests/value-objects/hashes/SHA512Hash.spec.ts +0 -220
  452. package/tests/value-objects/ids/ShortId.spec.ts +0 -34
  453. package/tests/value-objects/ids/UUID.spec.ts +0 -37
  454. package/tests/value-objects/time/CalendarDay.spec.ts +0 -182
  455. package/tests/value-objects/time/Day.spec.ts +0 -29
  456. package/tests/value-objects/time/DayOfWeek.spec.ts +0 -71
  457. package/tests/value-objects/time/Duration.spec.ts +0 -278
  458. package/tests/value-objects/time/Hour.spec.ts +0 -197
  459. package/tests/value-objects/time/MonthOfYear.spec.ts +0 -111
  460. package/tests/value-objects/time/Timestamp.spec.ts +0 -497
  461. package/tests/value-objects/time/TimestampInterval.spec.ts +0 -383
  462. package/tests/value-objects/time/Year.spec.ts +0 -48
  463. package/tsconfig.jest.json +0 -33
  464. package/tsconfig.json +0 -42
@@ -1,37 +0,0 @@
1
- import { InvalidFormatError } from '../../../src/errors/InvalidFormatError';
2
- import { InvalidLengthError } from '../../../src/errors/InvalidLengthError';
3
- import { UUID } from '../../../src/value-objects/ids/UUID';
4
-
5
- describe('UUID', () => {
6
- describe('generate', () => {
7
- it('should generate a valid LongId', () => {
8
- const id = UUID.generate();
9
- expect(id).toBeInstanceOf(UUID);
10
- expect(id.toString()).toHaveLength(36);
11
- });
12
- });
13
- describe('constructor', () => {
14
- it('should throw invalid length error when constructor receives a empty string', () => {
15
- expect(() => new UUID('')).toThrow(InvalidLengthError);
16
- });
17
-
18
- it('should throw invalid format when value is not a valid id', () => {
19
- expect(() => new UUID('123')).toThrow(InvalidLengthError);
20
- });
21
-
22
- it("should be a valid id when it's 36 length string", () => {
23
- expect(
24
- () => new UUID('8ab0b0f7-7324-4637-bc6b-109326f081c0'),
25
- ).not.toThrow();
26
- expect(new UUID('8ab0b0f7-7324-4637-bc6b-109326f081c0')).toBeInstanceOf(
27
- UUID,
28
- );
29
- });
30
-
31
- it("should be invalid id when it's 36 length but invalid characters", () => {
32
- expect(() => new UUID('8ab0b0f7-7324#5637-bc6b-109326f081c0')).toThrow(
33
- InvalidFormatError,
34
- );
35
- });
36
- });
37
- });
@@ -1,182 +0,0 @@
1
- import {
2
- Timestamp,
3
- CalendarDay,
4
- InvalidDayError,
5
- Month,
6
- Day,
7
- DayOfWeek,
8
- Year,
9
- InvalidDayFormatError,
10
- } from '../../../src';
11
-
12
- /* eslint-disable @typescript-eslint/no-unsafe-call */
13
- describe('CalendarDay', () => {
14
- describe('constructor', () => {
15
- it('should create a CalendarDay ', () => {
16
- const now = new Timestamp();
17
- const day = new CalendarDay();
18
- expect(day).toMatchObject({
19
- year: now.getYear().valueOf(),
20
- month: now.getMonth().valueOf(),
21
- day: now.getDay().valueOf(),
22
- });
23
- });
24
-
25
- it('should create a day instance with a valid date string', () => {
26
- const day = new CalendarDay('2022-01-01');
27
- expect(day).toMatchObject({
28
- year: 2022,
29
- month: 1,
30
- day: 1,
31
- });
32
- });
33
-
34
- it('should create a day instance with a valid Timestamp', () => {
35
- const day = new CalendarDay(new Timestamp('2022-01-01'));
36
- expect(day).toMatchObject({
37
- year: 2022,
38
- month: 1,
39
- day: 1,
40
- });
41
- });
42
-
43
- it('should create a day instance with a valid Date', () => {
44
- const day = new CalendarDay(new Date('2022-01-01'));
45
- expect(day).toMatchObject({
46
- year: 2022,
47
- month: 1,
48
- day: 1,
49
- });
50
- });
51
-
52
- it('should create a day instance with a valid number', () => {
53
- const day = new CalendarDay(1640995200000);
54
- expect(day).toMatchObject({
55
- year: 2022,
56
- month: 1,
57
- day: 1,
58
- });
59
- });
60
-
61
- it('should throw InvalidDateFormatError when provided with an invalid date string', () => {
62
- expect(() => new CalendarDay('2022-01-001')).toThrow(
63
- InvalidDayFormatError,
64
- );
65
- });
66
-
67
- it('should throw InvalidDateFormatError when provided with an invalid date string', () => {
68
- expect(() => new CalendarDay('2022-01')).toThrow(InvalidDayFormatError);
69
- });
70
-
71
- it('should throw InvalidDateFormatError when provided with an invalid date', () => {
72
- expect(() => new CalendarDay(new Date(NaN))).toThrow(InvalidDayError);
73
- });
74
- });
75
-
76
- describe('valueOf', () => {
77
- it('should return the date value as a string', () => {
78
- const day = new CalendarDay('2022-01-01');
79
- expect(day.valueOf()).toBe('2022-01-01');
80
- });
81
- });
82
-
83
- describe('isEqual', () => {
84
- it('should return true when two days have the same value', () => {
85
- const day1 = new CalendarDay('2022-01-01');
86
- const day2 = new CalendarDay('2022-01-01');
87
- expect(day1.isEqual(day2)).toBe(true);
88
- });
89
-
90
- it('should return false when two days have different values', () => {
91
- const day1 = new CalendarDay('2022-01-01');
92
- const day2 = new CalendarDay('2022-01-02');
93
- expect(day1.isEqual(day2)).toBe(false);
94
- });
95
- });
96
-
97
- describe('isAfter', () => {
98
- it('should return true when the current day is after the provided day', () => {
99
- const day1 = new CalendarDay('2022-01-02');
100
- const day2 = new CalendarDay('2022-01-01');
101
- expect(day1.isAfter(day2)).toBe(true);
102
- });
103
-
104
- it('should return false when the current day is not after the provided day', () => {
105
- const day1 = new CalendarDay('2022-01-01');
106
- const day2 = new CalendarDay('2022-01-02');
107
- expect(day1.isAfter(day2)).toBe(false);
108
- });
109
- });
110
-
111
- describe('isBefore', () => {
112
- it('should return true when the current day is before the provided day', () => {
113
- const day1 = new CalendarDay('2022-01-01');
114
- const day2 = new CalendarDay('2022-01-02');
115
- expect(day1.isBefore(day2)).toBe(true);
116
- });
117
-
118
- it('should return false when the current day is not before the provided day', () => {
119
- const day1 = new CalendarDay('2022-01-02');
120
- const day2 = new CalendarDay('2022-01-01');
121
- expect(day1.isBefore(day2)).toBe(false);
122
- });
123
- });
124
- describe('getYear', () => {
125
- it('should return the year of the day', () => {
126
- const day = new CalendarDay('2022-01-02');
127
- expect(day.getYear()).toBe(2022);
128
- });
129
- });
130
- describe('getMonth', () => {
131
- it('should return the Month of the day', () => {
132
- const day = new CalendarDay('2022-01-02');
133
- expect(day.getMonth()).toStrictEqual(Month.JANUARY);
134
- });
135
- });
136
- describe('getDay', () => {
137
- it('should return the year of the day', () => {
138
- const day = new CalendarDay('2022-01-02');
139
- expect(day.getDay()).toStrictEqual(new Day(2));
140
- });
141
- });
142
- describe('getDayOfWeek', () => {
143
- it('should return the correct DayOfWeek for a given date', () => {
144
- expect(new CalendarDay('2025-01-05').getDayOfWeek()).toEqual(
145
- DayOfWeek.SUNDAY,
146
- );
147
- expect(new CalendarDay('2025-01-31').getDayOfWeek()).toEqual(
148
- DayOfWeek.FRIDAY,
149
- );
150
- expect(new CalendarDay('2025-02-28').getDayOfWeek()).toEqual(
151
- DayOfWeek.FRIDAY,
152
- );
153
- expect(new CalendarDay('2024-12-31').getDayOfWeek()).toEqual(
154
- DayOfWeek.TUESDAY,
155
- );
156
- });
157
-
158
- describe('toTimestamp', () => {
159
- it('should return the correct Timestamp instance', () => {
160
- const timestamp = new Timestamp('2022-01-01');
161
- const day = new CalendarDay(timestamp);
162
- expect(day.toTimestamp()).toStrictEqual(timestamp);
163
- });
164
-
165
- it('should return a Timestamp instance matching the date value', () => {
166
- const day = new CalendarDay('2022-01-01');
167
- const timestamp = day.toTimestamp();
168
- expect(timestamp.valueOf()).toBe(new Timestamp('2022-01-01').valueOf());
169
- });
170
- });
171
- describe('getMonthOfYear', () => {
172
- it('should return a MonthOfYear instance with the correct month and year', () => {
173
- const day = new CalendarDay('2022-01-02');
174
- const month = day.getMonthOfYear();
175
- expect(month).toMatchObject({
176
- month: Month.JANUARY,
177
- year: new Year(2022),
178
- });
179
- });
180
- });
181
- });
182
- });
@@ -1,29 +0,0 @@
1
- import { Day, InvalidDayError, NumberValueObject } from '../../../src';
2
-
3
- describe('Day', () => {
4
- it('should create a valid Day instance for a value within the valid range', () => {
5
- expect(() => new Day(1)).not.toThrow();
6
- expect(() => new Day(15)).not.toThrow();
7
- expect(() => new Day(31)).not.toThrow();
8
- });
9
-
10
- it('should throw InvalidDayError for a value less than 1', () => {
11
- expect(() => new Day(0)).toThrow(InvalidDayError);
12
- expect(() => new Day(-1)).toThrow(InvalidDayError);
13
- });
14
-
15
- it('should throw InvalidDayError for a value greater than 31', () => {
16
- expect(() => new Day(32)).toThrow(InvalidDayError);
17
- expect(() => new Day(100)).toThrow(InvalidDayError);
18
- });
19
-
20
- it('should accept a NumberValueObject as input', () => {
21
- expect(() => new Day(new NumberValueObject(3))).not.toThrow();
22
- });
23
- it('should be not equal to another Day with a different value', () => {
24
- const day1 = new Day(1);
25
- const day2 = new Day(2);
26
- expect(day1.isEqual(day2)).toBe(false);
27
- expect(day1.isNotEqual(day2)).toBe(true);
28
- });
29
- });
@@ -1,71 +0,0 @@
1
- import { DayOfWeek, Timestamp, EDaysOfWeek } from '../../../src';
2
-
3
- describe('DayOfWeek', () => {
4
- describe('fromNumber', () => {
5
- it('should create the correct Day instance from a number', () => {
6
- expect(
7
- DayOfWeek.fromNumber(new Timestamp('2024-05-27').getDayOfWeek()),
8
- ).toEqual(DayOfWeek.MONDAY);
9
- expect(
10
- DayOfWeek.fromNumber(new Timestamp('2024-05-28').getDayOfWeek()),
11
- ).toEqual(DayOfWeek.TUESDAY);
12
- expect(
13
- DayOfWeek.fromNumber(new Timestamp('2024-05-29').getDayOfWeek()),
14
- ).toEqual(DayOfWeek.WEDNESDAY);
15
- expect(
16
- DayOfWeek.fromNumber(new Timestamp('2024-05-30').getDayOfWeek()),
17
- ).toEqual(DayOfWeek.THURSDAY);
18
- expect(
19
- DayOfWeek.fromNumber(new Timestamp('2024-05-31').getDayOfWeek()),
20
- ).toEqual(DayOfWeek.FRIDAY);
21
- expect(
22
- DayOfWeek.fromNumber(new Timestamp('2024-06-01').getDayOfWeek()),
23
- ).toEqual(DayOfWeek.SATURDAY);
24
- expect(
25
- DayOfWeek.fromNumber(new Timestamp('2024-06-02').getDayOfWeek()),
26
- ).toEqual(DayOfWeek.SUNDAY);
27
- });
28
-
29
- it('should throw an error when an invalid number is provided', () => {
30
- expect(() => {
31
- DayOfWeek.fromNumber(23);
32
- }).toThrow();
33
- });
34
- });
35
- describe('toNumber', () => {
36
- it('should return the correct number for a day', () => {
37
- expect(DayOfWeek.MONDAY.toNumber()).toEqual(1);
38
- expect(DayOfWeek.TUESDAY.toNumber()).toEqual(2);
39
- expect(DayOfWeek.WEDNESDAY.toNumber()).toEqual(3);
40
- expect(DayOfWeek.THURSDAY.toNumber()).toEqual(4);
41
- expect(DayOfWeek.FRIDAY.toNumber()).toEqual(5);
42
- expect(DayOfWeek.SATURDAY.toNumber()).toEqual(6);
43
- expect(DayOfWeek.SUNDAY.toNumber()).toEqual(0);
44
- });
45
- });
46
- describe('fromTimestamp', () => {
47
- it('should create the correct Day instance from a timestamp', () => {
48
- expect(DayOfWeek.fromTimestamp(new Timestamp('2024-05-27'))).toEqual(
49
- DayOfWeek.MONDAY,
50
- );
51
- expect(DayOfWeek.fromTimestamp(new Timestamp('2024-05-28'))).toEqual(
52
- DayOfWeek.TUESDAY,
53
- );
54
- expect(DayOfWeek.fromTimestamp(new Timestamp('2024-05-29'))).toEqual(
55
- DayOfWeek.WEDNESDAY,
56
- );
57
- expect(DayOfWeek.fromTimestamp(new Timestamp('2024-05-30'))).toEqual(
58
- DayOfWeek.THURSDAY,
59
- );
60
- expect(DayOfWeek.fromTimestamp(new Timestamp('2024-05-31'))).toEqual(
61
- DayOfWeek.FRIDAY,
62
- );
63
- expect(DayOfWeek.fromTimestamp(new Timestamp('2024-06-01'))).toEqual(
64
- DayOfWeek.SATURDAY,
65
- );
66
- expect(DayOfWeek.fromTimestamp(new Timestamp('2024-06-02'))).toEqual(
67
- DayOfWeek.SUNDAY,
68
- );
69
- });
70
- });
71
- });
@@ -1,278 +0,0 @@
1
- import { Duration } from '../../../src';
2
-
3
- describe('Duration', () => {
4
- describe('fromDays', () => {
5
- it('should create a Time instance from days', () => {
6
- const days = 2;
7
- const expectedMilliseconds = 2 * 24 * 60 * 60 * 1000;
8
- const time = Duration.fromDays(days);
9
- expect(time.valueOf()).toBe(expectedMilliseconds);
10
- });
11
- });
12
-
13
- describe('fromHours', () => {
14
- it('should create a Time instance from hours', () => {
15
- const hours = 2;
16
- const expectedMilliseconds = 2 * 60 * 60 * 1000;
17
- const time = Duration.fromHours(hours);
18
- expect(time.valueOf()).toBe(expectedMilliseconds);
19
- });
20
- });
21
-
22
- describe('fromMinutes', () => {
23
- it('should create a Time instance from minutes', () => {
24
- const minutes = 30;
25
- const expectedMilliseconds = 30 * 60 * 1000;
26
- const time = Duration.fromMinutes(minutes);
27
- expect(time.valueOf()).toBe(expectedMilliseconds);
28
- });
29
- });
30
-
31
- describe('fromSeconds', () => {
32
- it('should create a Time instance from seconds', () => {
33
- const seconds = 45;
34
- const expectedMilliseconds = 45 * 1000;
35
- const time = Duration.fromSeconds(seconds);
36
- expect(time.valueOf()).toBe(expectedMilliseconds);
37
- });
38
- });
39
-
40
- describe('fromMilliseconds', () => {
41
- it('should create a Time instance from milliseconds', () => {
42
- const milliseconds = 500;
43
- const time = Duration.fromMilliseconds(milliseconds);
44
- expect(time.valueOf()).toBe(milliseconds);
45
- });
46
- });
47
-
48
- describe('getTotalDays', () => {
49
- it('should return the total days', () => {
50
- const milliseconds = 2 * 24 * 60 * 60 * 1000;
51
- const time = Duration.fromMilliseconds(milliseconds);
52
- const totalDays = time.getTotalDays();
53
- expect(totalDays.valueOf()).toBe(2);
54
- });
55
- it('should keep the value after getting it', () => {
56
- const milliseconds = 2 * 24 * 60 * 60 * 1000;
57
- const time = Duration.fromMilliseconds(milliseconds);
58
- const firstTime = time.getTotalDays();
59
- const secondTime = time.getTotalDays();
60
-
61
- expect(firstTime.valueOf()).toBe(2);
62
- expect(secondTime.valueOf()).toBe(2);
63
- });
64
- });
65
-
66
- describe('getTotalHours', () => {
67
- it('should return the total hours', () => {
68
- const milliseconds = 2 * 60 * 60 * 1000;
69
- const time = Duration.fromMilliseconds(milliseconds);
70
- const totalHours = time.getTotalHours();
71
- expect(totalHours.valueOf()).toBe(2);
72
- });
73
- it('should keep the value after getting it', () => {
74
- const milliseconds = 2 * 60 * 60 * 1000;
75
- const time = Duration.fromMilliseconds(milliseconds);
76
- const firstTime = time.getTotalHours();
77
- const secondTime = time.getTotalHours();
78
-
79
- expect(firstTime.valueOf()).toBe(2);
80
- expect(secondTime.valueOf()).toBe(2);
81
- });
82
- });
83
-
84
- describe('getTotalMinutes', () => {
85
- it('should return the total minutes', () => {
86
- const milliseconds = 3000 * 60 * 1000;
87
- const time = Duration.fromMilliseconds(milliseconds);
88
- const totalMinutes = time.getTotalMinutes();
89
- expect(totalMinutes.valueOf()).toBe(3000);
90
- });
91
- it('should keep the value after getting it', () => {
92
- const milliseconds = 3000 * 60 * 1000;
93
- const time = Duration.fromMilliseconds(milliseconds);
94
- const firstTime = time.getTotalMinutes();
95
- const secondTime = time.getTotalMinutes();
96
-
97
- expect(firstTime.valueOf()).toBe(3000);
98
- expect(secondTime.valueOf()).toBe(3000);
99
- });
100
- });
101
-
102
- describe('getTotalSeconds', () => {
103
- it('should return the total seconds', () => {
104
- const milliseconds = 450 * 1000;
105
- const time = Duration.fromMilliseconds(milliseconds);
106
- const totalSeconds = time.getTotalSeconds();
107
- expect(totalSeconds.valueOf()).toBe(450);
108
- });
109
- it('should keep the value after getting it', () => {
110
- const milliseconds = 450 * 1000;
111
- const time = Duration.fromMilliseconds(milliseconds);
112
- const firstTime = time.getTotalSeconds();
113
- const secondTime = time.getTotalSeconds();
114
-
115
- expect(firstTime.valueOf()).toBe(450);
116
- expect(secondTime.valueOf()).toBe(450);
117
- });
118
- });
119
-
120
- describe('getTotalMilliseconds', () => {
121
- it('should return the total milliseconds', () => {
122
- const milliseconds = 5000000;
123
- const time = Duration.fromMilliseconds(milliseconds);
124
- const totalMilliseconds = time.getTotalMilliseconds();
125
- expect(totalMilliseconds.valueOf()).toBe(milliseconds);
126
- });
127
- it('should return the total milliseconds', () => {
128
- const milliseconds = 500;
129
- const time = Duration.fromMilliseconds(milliseconds);
130
- const totalMilliseconds = time.getTotalMilliseconds();
131
- expect(totalMilliseconds.valueOf()).toBe(milliseconds);
132
- });
133
- it('should keep the value after getting it', () => {
134
- const milliseconds = 3000 * 60 * 1000;
135
- const time = Duration.fromMilliseconds(milliseconds);
136
- const firstTime = time.getTotalMilliseconds();
137
- const secondTime = time.getTotalMilliseconds();
138
-
139
- expect(firstTime.valueOf()).toBe(milliseconds);
140
- expect(secondTime.valueOf()).toBe(milliseconds);
141
- });
142
- });
143
-
144
- describe('getDays', () => {
145
- it('should return the days', () => {
146
- const milliseconds = 2 * 24 * 60 * 60 * 1000;
147
- const time = Duration.fromMilliseconds(milliseconds);
148
- const days = time.getDays();
149
- expect(days.valueOf()).toBe(2);
150
- });
151
- it('should return the days when there are hours and milliseconds', () => {
152
- let milliseconds = 2 * 24 * 60 * 60 * 1000;
153
- milliseconds += 2 * 60 * 60 * 1000;
154
- const time = Duration.fromMilliseconds(milliseconds);
155
- const days = time.getDays();
156
- expect(days.valueOf()).toBe(2);
157
- });
158
- it('should return the days', () => {
159
- const milliseconds = 976940000;
160
- const time = Duration.fromMilliseconds(milliseconds);
161
- const days = time.getDays();
162
- expect(days.valueOf()).toBe(11);
163
- });
164
- it('should keep the value after getting it', () => {
165
- const milliseconds = 976940000;
166
- const time = Duration.fromMilliseconds(milliseconds);
167
- const firstTime = time.getDays();
168
- const secondTime = time.getDays();
169
-
170
- expect(firstTime.valueOf()).toBe(11);
171
- expect(secondTime.valueOf()).toBe(11);
172
- });
173
- });
174
-
175
- describe('getHours', () => {
176
- it('should return the hours', () => {
177
- const milliseconds = 2 * 60 * 60 * 1000;
178
- const time = Duration.fromMilliseconds(milliseconds);
179
- const hours = time.getHours();
180
- expect(hours.valueOf()).toBe(2);
181
- });
182
- it('should return the hours when there are minutes and milliseconds', () => {
183
- let milliseconds = 2 * 60 * 60 * 1000;
184
- milliseconds += 30 * 60 * 1000;
185
- const time = Duration.fromMilliseconds(milliseconds);
186
- const hours = time.getHours();
187
- expect(hours.valueOf()).toBe(2);
188
- });
189
- it('should return the hours', () => {
190
- const milliseconds = 35940000;
191
- const time = Duration.fromMilliseconds(milliseconds);
192
- const minutes = time.getHours();
193
- expect(minutes.valueOf()).toBe(9);
194
- });
195
- it('should keep the value after getting it', () => {
196
- const milliseconds = 35940000;
197
- const time = Duration.fromMilliseconds(milliseconds);
198
- const firstTime = time.getHours();
199
- const secondTime = time.getHours();
200
-
201
- expect(firstTime.valueOf()).toBe(9);
202
- expect(secondTime.valueOf()).toBe(9);
203
- });
204
- });
205
-
206
- describe('getMinutes', () => {
207
- it('should return the minutes', () => {
208
- const milliseconds = 30 * 60 * 1000;
209
- const time = Duration.fromMilliseconds(milliseconds);
210
- const minutes = time.getMinutes();
211
- expect(minutes.valueOf()).toBe(30);
212
- });
213
- it('should return the minutes', () => {
214
- const milliseconds = 35940000;
215
- const time = Duration.fromMilliseconds(milliseconds);
216
- const minutes = time.getMinutes();
217
- expect(minutes.valueOf()).toBe(59);
218
- });
219
- it('should keep the value after getting it', () => {
220
- const milliseconds = 35940000;
221
- const time = Duration.fromMilliseconds(milliseconds);
222
- const firstTime = time.getMinutes();
223
- const secondTime = time.getMinutes();
224
-
225
- expect(firstTime.valueOf()).toBe(59);
226
- expect(secondTime.valueOf()).toBe(59);
227
- });
228
- });
229
-
230
- describe('getSeconds', () => {
231
- it('should return the seconds', () => {
232
- const milliseconds = 45 * 1000;
233
- const time = Duration.fromMilliseconds(milliseconds);
234
- const seconds = time.getSeconds();
235
- expect(seconds.valueOf()).toBe(45);
236
- });
237
- it('should return the seconds', () => {
238
- const milliseconds = 70 * 1000;
239
- const time = Duration.fromMilliseconds(milliseconds);
240
- const minutes = time.getSeconds();
241
- expect(minutes.valueOf()).toBe(10);
242
- });
243
- it('should keep the value after getting it', () => {
244
- const milliseconds = 45 * 1000;
245
- const time = Duration.fromMilliseconds(milliseconds);
246
- const firstTime = time.getSeconds();
247
- const secondTime = time.getSeconds();
248
-
249
- expect(firstTime.valueOf()).toBe(45);
250
- expect(secondTime.valueOf()).toBe(45);
251
- });
252
- });
253
-
254
- describe('getMilliseconds', () => {
255
- it('should return the milliseconds', () => {
256
- const milliseconds = 1500;
257
- const time = Duration.fromMilliseconds(milliseconds);
258
- expect(time.getMilliseconds().valueOf()).toBe(500);
259
- });
260
- it('should keep the value after getting it', () => {
261
- const milliseconds = 1500;
262
- const time = Duration.fromMilliseconds(milliseconds);
263
- const firstTime = time.getMilliseconds();
264
- const secondTime = time.getMilliseconds();
265
-
266
- expect(firstTime.valueOf()).toBe(500);
267
- expect(secondTime.valueOf()).toBe(500);
268
- });
269
- });
270
-
271
- describe('valueOf', () => {
272
- it('should return the value in milliseconds', () => {
273
- const milliseconds = 500;
274
- const time = Duration.fromMilliseconds(milliseconds);
275
- expect(time.valueOf()).toBe(milliseconds);
276
- });
277
- });
278
- });