@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.
- package/dist/src/errors/BaseError.d.ts +8 -0
- package/dist/src/errors/BaseError.d.ts.map +1 -0
- package/dist/src/errors/BaseError.js +22 -0
- package/dist/src/errors/BaseError.js.map +1 -0
- package/dist/src/errors/DomainError.d.ts +7 -0
- package/dist/src/errors/DomainError.d.ts.map +1 -0
- package/dist/src/errors/DomainError.js +15 -0
- package/dist/src/errors/DomainError.js.map +1 -0
- package/dist/src/errors/InvalidColorError.d.ts +5 -0
- package/dist/src/errors/InvalidColorError.d.ts.map +1 -0
- package/dist/src/errors/InvalidColorError.js +11 -0
- package/dist/src/errors/InvalidColorError.js.map +1 -0
- package/dist/src/errors/InvalidDayError.d.ts +5 -0
- package/dist/src/errors/InvalidDayError.d.ts.map +1 -0
- package/dist/src/errors/InvalidDayError.js +11 -0
- package/dist/src/errors/InvalidDayError.js.map +1 -0
- package/dist/src/errors/InvalidDayFormatError.d.ts +5 -0
- package/dist/src/errors/InvalidDayFormatError.d.ts.map +1 -0
- package/dist/src/errors/InvalidDayFormatError.js +11 -0
- package/dist/src/errors/InvalidDayFormatError.js.map +1 -0
- package/dist/src/errors/InvalidEmailError.d.ts +5 -0
- package/dist/src/errors/InvalidEmailError.d.ts.map +1 -0
- package/dist/src/errors/InvalidEmailError.js +11 -0
- package/dist/src/errors/InvalidEmailError.js.map +1 -0
- package/dist/src/errors/InvalidFormatError.d.ts +5 -0
- package/dist/src/errors/InvalidFormatError.d.ts.map +1 -0
- package/dist/src/errors/InvalidFormatError.js +11 -0
- package/dist/src/errors/InvalidFormatError.js.map +1 -0
- package/dist/src/errors/InvalidHashError.d.ts +5 -0
- package/dist/src/errors/InvalidHashError.d.ts.map +1 -0
- package/dist/src/errors/InvalidHashError.js +11 -0
- package/dist/src/errors/InvalidHashError.js.map +1 -0
- package/dist/src/errors/InvalidHourError.d.ts +5 -0
- package/dist/src/errors/InvalidHourError.d.ts.map +1 -0
- package/dist/src/errors/InvalidHourError.js +11 -0
- package/dist/src/errors/InvalidHourError.js.map +1 -0
- package/dist/src/errors/InvalidIntegerError.d.ts +5 -0
- package/dist/src/errors/InvalidIntegerError.d.ts.map +1 -0
- package/dist/src/errors/InvalidIntegerError.js +11 -0
- package/dist/src/errors/InvalidIntegerError.js.map +1 -0
- package/dist/src/errors/InvalidLatitudeError.d.ts +5 -0
- package/dist/src/errors/InvalidLatitudeError.d.ts.map +1 -0
- package/dist/src/errors/InvalidLatitudeError.js +11 -0
- package/dist/src/errors/InvalidLatitudeError.js.map +1 -0
- package/dist/src/errors/InvalidLengthError.d.ts +5 -0
- package/dist/src/errors/InvalidLengthError.d.ts.map +1 -0
- package/dist/src/errors/InvalidLengthError.js +11 -0
- package/dist/src/errors/InvalidLengthError.js.map +1 -0
- package/dist/src/errors/InvalidLongitudeError.d.ts +5 -0
- package/dist/src/errors/InvalidLongitudeError.d.ts.map +1 -0
- package/dist/src/errors/InvalidLongitudeError.js +11 -0
- package/dist/src/errors/InvalidLongitudeError.js.map +1 -0
- package/dist/src/errors/InvalidMinutesError.d.ts +5 -0
- package/dist/src/errors/InvalidMinutesError.d.ts.map +1 -0
- package/dist/src/errors/InvalidMinutesError.js +11 -0
- package/dist/src/errors/InvalidMinutesError.js.map +1 -0
- package/dist/src/errors/InvalidNumberError.d.ts +5 -0
- package/dist/src/errors/InvalidNumberError.d.ts.map +1 -0
- package/dist/src/errors/InvalidNumberError.js +11 -0
- package/dist/src/errors/InvalidNumberError.js.map +1 -0
- package/dist/src/errors/InvalidPositiveNumberError.d.ts +5 -0
- package/dist/src/errors/InvalidPositiveNumberError.d.ts.map +1 -0
- package/dist/src/errors/InvalidPositiveNumberError.js +11 -0
- package/dist/src/errors/InvalidPositiveNumberError.js.map +1 -0
- package/dist/src/errors/InvalidStringLengthError.d.ts +5 -0
- package/dist/src/errors/InvalidStringLengthError.d.ts.map +1 -0
- package/dist/src/errors/InvalidStringLengthError.js +11 -0
- package/dist/src/errors/InvalidStringLengthError.js.map +1 -0
- package/dist/src/errors/InvalidTimestampIntervalError.d.ts +6 -0
- package/dist/src/errors/InvalidTimestampIntervalError.d.ts.map +1 -0
- package/dist/src/errors/InvalidTimestampIntervalError.js +11 -0
- package/dist/src/errors/InvalidTimestampIntervalError.js.map +1 -0
- package/dist/src/errors/InvalidValueError.d.ts +5 -0
- package/dist/src/errors/InvalidValueError.d.ts.map +1 -0
- package/dist/src/errors/InvalidValueError.js +11 -0
- package/dist/src/errors/InvalidValueError.js.map +1 -0
- package/dist/src/errors/NullObjectError.d.ts +5 -0
- package/dist/src/errors/NullObjectError.d.ts.map +1 -0
- package/dist/src/errors/NullObjectError.js +12 -0
- package/dist/src/errors/NullObjectError.js.map +1 -0
- package/dist/src/errors/ValueNotInEnumError.d.ts +5 -0
- package/dist/src/errors/ValueNotInEnumError.d.ts.map +1 -0
- package/dist/src/errors/ValueNotInEnumError.js +11 -0
- package/dist/src/errors/ValueNotInEnumError.js.map +1 -0
- package/{src/errors/index.ts → dist/src/errors/index.d.ts} +1 -0
- package/dist/src/errors/index.d.ts.map +1 -0
- package/dist/src/errors/index.js +24 -0
- package/dist/src/errors/index.js.map +1 -0
- package/{src/index.ts → dist/src/index.d.ts} +1 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +9 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/interfaces/PrimitiveOf.d.ts +5 -0
- package/dist/src/interfaces/PrimitiveOf.d.ts.map +1 -0
- package/dist/src/interfaces/PrimitiveOf.js +3 -0
- package/dist/src/interfaces/PrimitiveOf.js.map +1 -0
- package/dist/src/interfaces/index.d.ts +2 -0
- package/dist/src/interfaces/index.d.ts.map +1 -0
- package/dist/src/interfaces/index.js +5 -0
- package/dist/src/interfaces/index.js.map +1 -0
- package/dist/src/patterns/Assert.d.ts +5 -0
- package/dist/src/patterns/Assert.d.ts.map +1 -0
- package/dist/src/patterns/Assert.js +11 -0
- package/dist/src/patterns/Assert.js.map +1 -0
- package/dist/src/patterns/index.d.ts +2 -0
- package/dist/src/patterns/index.d.ts.map +1 -0
- package/dist/src/patterns/index.js +5 -0
- package/dist/src/patterns/index.js.map +1 -0
- package/{src/types/Nullish.ts → dist/src/types/Nullish.d.ts} +1 -0
- package/dist/src/types/Nullish.d.ts.map +1 -0
- package/dist/src/types/Nullish.js +3 -0
- package/dist/src/types/Nullish.js.map +1 -0
- package/{src/types/Primitive.ts → dist/src/types/Primitive.d.ts} +1 -0
- package/dist/src/types/Primitive.d.ts.map +1 -0
- package/dist/src/types/Primitive.js +3 -0
- package/dist/src/types/Primitive.js.map +1 -0
- package/{src/types/index.ts → dist/src/types/index.d.ts} +1 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/index.js +6 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/value-objects/Color.d.ts +19 -0
- package/dist/src/value-objects/Color.d.ts.map +1 -0
- package/dist/src/value-objects/Color.js +37 -0
- package/dist/src/value-objects/Color.js.map +1 -0
- package/dist/src/value-objects/Email.d.ts +6 -0
- package/dist/src/value-objects/Email.d.ts.map +1 -0
- package/dist/src/value-objects/Email.js +21 -0
- package/dist/src/value-objects/Email.js.map +1 -0
- package/dist/src/value-objects/Enum.d.ts +9 -0
- package/dist/src/value-objects/Enum.d.ts.map +1 -0
- package/dist/src/value-objects/Enum.js +24 -0
- package/dist/src/value-objects/Enum.js.map +1 -0
- package/dist/src/value-objects/Integer.d.ts +6 -0
- package/dist/src/value-objects/Integer.d.ts.map +1 -0
- package/dist/src/value-objects/Integer.js +21 -0
- package/dist/src/value-objects/Integer.js.map +1 -0
- package/dist/src/value-objects/NullObject.d.ts +8 -0
- package/dist/src/value-objects/NullObject.d.ts.map +1 -0
- package/dist/src/value-objects/NullObject.js +43 -0
- package/dist/src/value-objects/NullObject.js.map +1 -0
- package/dist/src/value-objects/NumberValueObject.d.ts +15 -0
- package/dist/src/value-objects/NumberValueObject.d.ts.map +1 -0
- package/dist/src/value-objects/NumberValueObject.js +48 -0
- package/dist/src/value-objects/NumberValueObject.js.map +1 -0
- package/dist/src/value-objects/PositiveNumber.d.ts +6 -0
- package/dist/src/value-objects/PositiveNumber.d.ts.map +1 -0
- package/dist/src/value-objects/PositiveNumber.js +21 -0
- package/dist/src/value-objects/PositiveNumber.js.map +1 -0
- package/dist/src/value-objects/StringValueObject.d.ts +7 -0
- package/dist/src/value-objects/StringValueObject.d.ts.map +1 -0
- package/dist/src/value-objects/StringValueObject.js +24 -0
- package/dist/src/value-objects/StringValueObject.js.map +1 -0
- package/dist/src/value-objects/ValueObject.d.ts +12 -0
- package/dist/src/value-objects/ValueObject.d.ts.map +1 -0
- package/dist/src/value-objects/ValueObject.js +33 -0
- package/dist/src/value-objects/ValueObject.js.map +1 -0
- package/dist/src/value-objects/coordinates/Coordinates.d.ts +12 -0
- package/dist/src/value-objects/coordinates/Coordinates.d.ts.map +1 -0
- package/dist/src/value-objects/coordinates/Coordinates.js +28 -0
- package/dist/src/value-objects/coordinates/Coordinates.js.map +1 -0
- package/dist/src/value-objects/coordinates/Latitude.d.ts +8 -0
- package/dist/src/value-objects/coordinates/Latitude.d.ts.map +1 -0
- package/dist/src/value-objects/coordinates/Latitude.js +21 -0
- package/dist/src/value-objects/coordinates/Latitude.js.map +1 -0
- package/dist/src/value-objects/coordinates/Longitude.d.ts +8 -0
- package/dist/src/value-objects/coordinates/Longitude.d.ts.map +1 -0
- package/dist/src/value-objects/coordinates/Longitude.js +21 -0
- package/dist/src/value-objects/coordinates/Longitude.js.map +1 -0
- package/{src/value-objects/coordinates/index.ts → dist/src/value-objects/coordinates/index.d.ts} +1 -0
- package/dist/src/value-objects/coordinates/index.d.ts.map +1 -0
- package/dist/src/value-objects/coordinates/index.js +7 -0
- package/dist/src/value-objects/coordinates/index.js.map +1 -0
- package/dist/src/value-objects/hashes/Hash.d.ts +7 -0
- package/dist/src/value-objects/hashes/Hash.d.ts.map +1 -0
- package/dist/src/value-objects/hashes/Hash.js +19 -0
- package/dist/src/value-objects/hashes/Hash.js.map +1 -0
- package/dist/src/value-objects/hashes/MD5Hash.d.ts +8 -0
- package/dist/src/value-objects/hashes/MD5Hash.d.ts.map +1 -0
- package/dist/src/value-objects/hashes/MD5Hash.js +26 -0
- package/dist/src/value-objects/hashes/MD5Hash.js.map +1 -0
- package/dist/src/value-objects/hashes/SHA256Hash.d.ts +9 -0
- package/dist/src/value-objects/hashes/SHA256Hash.d.ts.map +1 -0
- package/dist/src/value-objects/hashes/SHA256Hash.js +29 -0
- package/dist/src/value-objects/hashes/SHA256Hash.js.map +1 -0
- package/dist/src/value-objects/hashes/SHA512Hash.d.ts +9 -0
- package/dist/src/value-objects/hashes/SHA512Hash.d.ts.map +1 -0
- package/dist/src/value-objects/hashes/SHA512Hash.js +29 -0
- package/dist/src/value-objects/hashes/SHA512Hash.js.map +1 -0
- package/{src/value-objects/hashes/index.ts → dist/src/value-objects/hashes/index.d.ts} +1 -0
- package/dist/src/value-objects/hashes/index.d.ts.map +1 -0
- package/dist/src/value-objects/hashes/index.js +8 -0
- package/dist/src/value-objects/hashes/index.js.map +1 -0
- package/dist/src/value-objects/ids/ShortId.d.ts +10 -0
- package/dist/src/value-objects/ids/ShortId.d.ts.map +1 -0
- package/dist/src/value-objects/ids/ShortId.js +30 -0
- package/dist/src/value-objects/ids/ShortId.js.map +1 -0
- package/dist/src/value-objects/ids/UUID.d.ts +10 -0
- package/dist/src/value-objects/ids/UUID.d.ts.map +1 -0
- package/dist/src/value-objects/ids/UUID.js +29 -0
- package/dist/src/value-objects/ids/UUID.js.map +1 -0
- package/dist/src/value-objects/ids/index.d.ts +3 -0
- package/dist/src/value-objects/ids/index.d.ts.map +1 -0
- package/dist/src/value-objects/ids/index.js +6 -0
- package/dist/src/value-objects/ids/index.js.map +1 -0
- package/{src/value-objects/index.ts → dist/src/value-objects/index.d.ts} +2 -0
- package/dist/src/value-objects/index.d.ts.map +1 -0
- package/dist/src/value-objects/index.js +16 -0
- package/dist/src/value-objects/index.js.map +1 -0
- package/dist/src/value-objects/time/CalendarDay.d.ts +25 -0
- package/dist/src/value-objects/time/CalendarDay.d.ts.map +1 -0
- package/dist/src/value-objects/time/CalendarDay.js +74 -0
- package/dist/src/value-objects/time/CalendarDay.js.map +1 -0
- package/dist/src/value-objects/time/Day.d.ts +7 -0
- package/dist/src/value-objects/time/Day.d.ts.map +1 -0
- package/dist/src/value-objects/time/Day.js +18 -0
- package/dist/src/value-objects/time/Day.js.map +1 -0
- package/dist/src/value-objects/time/DayOfWeek.d.ts +34 -0
- package/dist/src/value-objects/time/DayOfWeek.d.ts.map +1 -0
- package/dist/src/value-objects/time/DayOfWeek.js +52 -0
- package/dist/src/value-objects/time/DayOfWeek.js.map +1 -0
- package/dist/src/value-objects/time/Duration.d.ts +23 -0
- package/dist/src/value-objects/time/Duration.d.ts.map +1 -0
- package/dist/src/value-objects/time/Duration.js +79 -0
- package/dist/src/value-objects/time/Duration.js.map +1 -0
- package/dist/src/value-objects/time/Hour.d.ts +15 -0
- package/dist/src/value-objects/time/Hour.d.ts.map +1 -0
- package/dist/src/value-objects/time/Hour.js +81 -0
- package/dist/src/value-objects/time/Hour.js.map +1 -0
- package/dist/src/value-objects/time/Month.d.ts +18 -0
- package/dist/src/value-objects/time/Month.d.ts.map +1 -0
- package/dist/src/value-objects/time/Month.js +41 -0
- package/dist/src/value-objects/time/Month.js.map +1 -0
- package/dist/src/value-objects/time/MonthOfYear.d.ts +17 -0
- package/dist/src/value-objects/time/MonthOfYear.d.ts.map +1 -0
- package/dist/src/value-objects/time/MonthOfYear.js +45 -0
- package/dist/src/value-objects/time/MonthOfYear.js.map +1 -0
- package/dist/src/value-objects/time/Timestamp.d.ts +51 -0
- package/dist/src/value-objects/time/Timestamp.d.ts.map +1 -0
- package/dist/src/value-objects/time/Timestamp.js +156 -0
- package/dist/src/value-objects/time/Timestamp.js.map +1 -0
- package/dist/src/value-objects/time/TimestampInterval.d.ts +26 -0
- package/dist/src/value-objects/time/TimestampInterval.d.ts.map +1 -0
- package/dist/src/value-objects/time/TimestampInterval.js +88 -0
- package/dist/src/value-objects/time/TimestampInterval.js.map +1 -0
- package/dist/src/value-objects/time/Year.d.ts +10 -0
- package/dist/src/value-objects/time/Year.d.ts.map +1 -0
- package/dist/src/value-objects/time/Year.js +26 -0
- package/dist/src/value-objects/time/Year.js.map +1 -0
- package/{src/value-objects/time/index.ts → dist/src/value-objects/time/index.d.ts} +1 -0
- package/dist/src/value-objects/time/index.d.ts.map +1 -0
- package/dist/src/value-objects/time/index.js +14 -0
- package/dist/src/value-objects/time/index.js.map +1 -0
- package/dist/tests/errors/BaseError.spec.d.ts +2 -0
- package/dist/tests/errors/BaseError.spec.d.ts.map +1 -0
- package/dist/tests/errors/BaseError.spec.js +54 -0
- package/dist/tests/errors/BaseError.spec.js.map +1 -0
- package/dist/tests/errors/DomainError.spec.d.ts +2 -0
- package/dist/tests/errors/DomainError.spec.d.ts.map +1 -0
- package/dist/tests/errors/DomainError.spec.js +47 -0
- package/dist/tests/errors/DomainError.spec.js.map +1 -0
- package/dist/tests/patterns/Assert.spec.d.ts +2 -0
- package/dist/tests/patterns/Assert.spec.d.ts.map +1 -0
- package/dist/tests/patterns/Assert.spec.js +27 -0
- package/dist/tests/patterns/Assert.spec.js.map +1 -0
- package/dist/tests/setup.jest.d.ts +2 -0
- package/dist/tests/setup.jest.d.ts.map +1 -0
- package/dist/tests/setup.jest.js +6 -0
- package/dist/tests/setup.jest.js.map +1 -0
- package/dist/tests/value-objects/Color.spec.d.ts +2 -0
- package/dist/tests/value-objects/Color.spec.d.ts.map +1 -0
- package/dist/tests/value-objects/Color.spec.js +171 -0
- package/dist/tests/value-objects/Color.spec.js.map +1 -0
- package/dist/tests/value-objects/Email.spec.d.ts +2 -0
- package/dist/tests/value-objects/Email.spec.d.ts.map +1 -0
- package/dist/tests/value-objects/Email.spec.js +117 -0
- package/dist/tests/value-objects/Email.spec.js.map +1 -0
- package/dist/tests/value-objects/Enum.spec.d.ts +2 -0
- package/dist/tests/value-objects/Enum.spec.d.ts.map +1 -0
- package/dist/tests/value-objects/Enum.spec.js +233 -0
- package/dist/tests/value-objects/Enum.spec.js.map +1 -0
- package/dist/tests/value-objects/Integer.spec.d.ts +2 -0
- package/dist/tests/value-objects/Integer.spec.d.ts.map +1 -0
- package/dist/tests/value-objects/Integer.spec.js +31 -0
- package/dist/tests/value-objects/Integer.spec.js.map +1 -0
- package/dist/tests/value-objects/NullObject.spec.d.ts +2 -0
- package/dist/tests/value-objects/NullObject.spec.d.ts.map +1 -0
- package/dist/tests/value-objects/NullObject.spec.js +48 -0
- package/dist/tests/value-objects/NullObject.spec.js.map +1 -0
- package/dist/tests/value-objects/NumberValueObject.spec.d.ts +2 -0
- package/dist/tests/value-objects/NumberValueObject.spec.d.ts.map +1 -0
- package/dist/tests/value-objects/NumberValueObject.spec.js +333 -0
- package/dist/tests/value-objects/NumberValueObject.spec.js.map +1 -0
- package/dist/tests/value-objects/PositiveNumber.spec.d.ts +2 -0
- package/dist/tests/value-objects/PositiveNumber.spec.d.ts.map +1 -0
- package/dist/tests/value-objects/PositiveNumber.spec.js +209 -0
- package/dist/tests/value-objects/PositiveNumber.spec.js.map +1 -0
- package/dist/tests/value-objects/StringValueObject.spec.d.ts +2 -0
- package/dist/tests/value-objects/StringValueObject.spec.d.ts.map +1 -0
- package/dist/tests/value-objects/StringValueObject.spec.js +104 -0
- package/dist/tests/value-objects/StringValueObject.spec.js.map +1 -0
- package/dist/tests/value-objects/coordinates/Coordinates.spec.d.ts +2 -0
- package/dist/tests/value-objects/coordinates/Coordinates.spec.d.ts.map +1 -0
- package/dist/tests/value-objects/coordinates/Coordinates.spec.js +76 -0
- package/dist/tests/value-objects/coordinates/Coordinates.spec.js.map +1 -0
- package/dist/tests/value-objects/coordinates/Latitude.spec.d.ts +2 -0
- package/dist/tests/value-objects/coordinates/Latitude.spec.d.ts.map +1 -0
- package/dist/tests/value-objects/coordinates/Latitude.spec.js +23 -0
- package/dist/tests/value-objects/coordinates/Latitude.spec.js.map +1 -0
- package/dist/tests/value-objects/coordinates/Longitude.spec.d.ts +2 -0
- package/dist/tests/value-objects/coordinates/Longitude.spec.d.ts.map +1 -0
- package/dist/tests/value-objects/coordinates/Longitude.spec.js +23 -0
- package/dist/tests/value-objects/coordinates/Longitude.spec.js.map +1 -0
- package/dist/tests/value-objects/hashes/Hashes.spec.d.ts +2 -0
- package/dist/tests/value-objects/hashes/Hashes.spec.d.ts.map +1 -0
- package/dist/tests/value-objects/hashes/Hashes.spec.js +107 -0
- package/dist/tests/value-objects/hashes/Hashes.spec.js.map +1 -0
- package/dist/tests/value-objects/hashes/MD5Hash.spec.d.ts +2 -0
- package/dist/tests/value-objects/hashes/MD5Hash.spec.d.ts.map +1 -0
- package/dist/tests/value-objects/hashes/MD5Hash.spec.js +147 -0
- package/dist/tests/value-objects/hashes/MD5Hash.spec.js.map +1 -0
- package/dist/tests/value-objects/hashes/SHA256Hash.spec.d.ts +2 -0
- package/dist/tests/value-objects/hashes/SHA256Hash.spec.d.ts.map +1 -0
- package/dist/tests/value-objects/hashes/SHA256Hash.spec.js +147 -0
- package/dist/tests/value-objects/hashes/SHA256Hash.spec.js.map +1 -0
- package/dist/tests/value-objects/hashes/SHA512Hash.spec.d.ts +2 -0
- package/dist/tests/value-objects/hashes/SHA512Hash.spec.d.ts.map +1 -0
- package/dist/tests/value-objects/hashes/SHA512Hash.spec.js +147 -0
- package/dist/tests/value-objects/hashes/SHA512Hash.spec.js.map +1 -0
- package/dist/tests/value-objects/ids/ShortId.spec.d.ts +2 -0
- package/dist/tests/value-objects/ids/ShortId.spec.d.ts.map +1 -0
- package/dist/tests/value-objects/ids/ShortId.spec.js +30 -0
- package/dist/tests/value-objects/ids/ShortId.spec.js.map +1 -0
- package/dist/tests/value-objects/ids/UUID.spec.d.ts +2 -0
- package/dist/tests/value-objects/ids/UUID.spec.d.ts.map +1 -0
- package/dist/tests/value-objects/ids/UUID.spec.js +30 -0
- package/dist/tests/value-objects/ids/UUID.spec.js.map +1 -0
- package/dist/tests/value-objects/time/CalendarDay.spec.d.ts +2 -0
- package/dist/tests/value-objects/time/CalendarDay.spec.d.ts.map +1 -0
- package/dist/tests/value-objects/time/CalendarDay.spec.js +149 -0
- package/dist/tests/value-objects/time/CalendarDay.spec.js.map +1 -0
- package/dist/tests/value-objects/time/Day.spec.d.ts +2 -0
- package/dist/tests/value-objects/time/Day.spec.d.ts.map +1 -0
- package/dist/tests/value-objects/time/Day.spec.js +28 -0
- package/dist/tests/value-objects/time/Day.spec.js.map +1 -0
- package/dist/tests/value-objects/time/DayOfWeek.spec.d.ts +2 -0
- package/dist/tests/value-objects/time/DayOfWeek.spec.d.ts.map +1 -0
- package/dist/tests/value-objects/time/DayOfWeek.spec.js +44 -0
- package/dist/tests/value-objects/time/DayOfWeek.spec.js.map +1 -0
- package/dist/tests/value-objects/time/Duration.spec.d.ts +2 -0
- package/dist/tests/value-objects/time/Duration.spec.d.ts.map +1 -0
- package/dist/tests/value-objects/time/Duration.spec.js +255 -0
- package/dist/tests/value-objects/time/Duration.spec.js.map +1 -0
- package/dist/tests/value-objects/time/Hour.spec.d.ts +2 -0
- package/dist/tests/value-objects/time/Hour.spec.d.ts.map +1 -0
- package/dist/tests/value-objects/time/Hour.spec.js +168 -0
- package/dist/tests/value-objects/time/Hour.spec.js.map +1 -0
- package/dist/tests/value-objects/time/MonthOfYear.spec.d.ts +2 -0
- package/dist/tests/value-objects/time/MonthOfYear.spec.d.ts.map +1 -0
- package/dist/tests/value-objects/time/MonthOfYear.spec.js +93 -0
- package/dist/tests/value-objects/time/MonthOfYear.spec.js.map +1 -0
- package/dist/tests/value-objects/time/Timestamp.spec.d.ts +2 -0
- package/dist/tests/value-objects/time/Timestamp.spec.d.ts.map +1 -0
- package/dist/tests/value-objects/time/Timestamp.spec.js +391 -0
- package/dist/tests/value-objects/time/Timestamp.spec.js.map +1 -0
- package/dist/tests/value-objects/time/TimestampInterval.spec.d.ts +2 -0
- package/dist/tests/value-objects/time/TimestampInterval.spec.d.ts.map +1 -0
- package/dist/tests/value-objects/time/TimestampInterval.spec.js +270 -0
- package/dist/tests/value-objects/time/TimestampInterval.spec.js.map +1 -0
- package/dist/tests/value-objects/time/Year.spec.d.ts +2 -0
- package/dist/tests/value-objects/time/Year.spec.d.ts.map +1 -0
- package/dist/tests/value-objects/time/Year.spec.js +41 -0
- package/dist/tests/value-objects/time/Year.spec.js.map +1 -0
- package/package.json +6 -2
- package/.editorconfig +0 -15
- package/.eslintignore +0 -3
- package/.eslintrc.json +0 -218
- package/.prettierrc.json +0 -13
- package/TECHNICAL_DOCUMENTATION.md +0 -1257
- package/jest.config.ts +0 -30
- package/src/errors/BaseError.ts +0 -20
- package/src/errors/DomainError.ts +0 -12
- package/src/errors/InvalidColorError.ts +0 -7
- package/src/errors/InvalidDayError.ts +0 -7
- package/src/errors/InvalidDayFormatError.ts +0 -7
- package/src/errors/InvalidEmailError.ts +0 -7
- package/src/errors/InvalidFormatError.ts +0 -7
- package/src/errors/InvalidHashError.ts +0 -7
- package/src/errors/InvalidHourError.ts +0 -7
- package/src/errors/InvalidIntegerError.ts +0 -7
- package/src/errors/InvalidLatitudeError.ts +0 -7
- package/src/errors/InvalidLengthError.ts +0 -9
- package/src/errors/InvalidLongitudeError.ts +0 -7
- package/src/errors/InvalidMinutesError.ts +0 -7
- package/src/errors/InvalidNumberError.ts +0 -7
- package/src/errors/InvalidPositiveNumberError.ts +0 -7
- package/src/errors/InvalidStringLengthError.ts +0 -9
- package/src/errors/InvalidTimestampIntervalError.ts +0 -10
- package/src/errors/InvalidValueError.ts +0 -7
- package/src/errors/NullObjectError.ts +0 -8
- package/src/errors/ValueNotInEnumError.ts +0 -9
- package/src/interfaces/PrimitiveOf.ts +0 -5
- package/src/interfaces/index.ts +0 -1
- package/src/patterns/Assert.ts +0 -15
- package/src/patterns/index.ts +0 -1
- package/src/value-objects/Color.ts +0 -39
- package/src/value-objects/Email.ts +0 -23
- package/src/value-objects/Enum.ts +0 -31
- package/src/value-objects/Integer.ts +0 -22
- package/src/value-objects/NullObject.ts +0 -60
- package/src/value-objects/NumberValueObject.ts +0 -56
- package/src/value-objects/PositiveNumber.ts +0 -20
- package/src/value-objects/StringValueObject.ts +0 -27
- package/src/value-objects/ValueObject.ts +0 -39
- package/src/value-objects/coordinates/Coordinates.ts +0 -30
- package/src/value-objects/coordinates/Latitude.ts +0 -22
- package/src/value-objects/coordinates/Longitude.ts +0 -25
- package/src/value-objects/hashes/Hash.ts +0 -19
- package/src/value-objects/hashes/MD5Hash.ts +0 -32
- package/src/value-objects/hashes/SHA256Hash.ts +0 -38
- package/src/value-objects/hashes/SHA512Hash.ts +0 -38
- package/src/value-objects/ids/ShortId.ts +0 -34
- package/src/value-objects/ids/UUID.ts +0 -34
- package/src/value-objects/time/CalendarDay.ts +0 -91
- package/src/value-objects/time/Day.ts +0 -17
- package/src/value-objects/time/DayOfWeek.ts +0 -60
- package/src/value-objects/time/Duration.ts +0 -142
- package/src/value-objects/time/Hour.ts +0 -105
- package/src/value-objects/time/Month.ts +0 -39
- package/src/value-objects/time/MonthOfYear.ts +0 -52
- package/src/value-objects/time/Timestamp.ts +0 -208
- package/src/value-objects/time/TimestampInterval.ts +0 -122
- package/src/value-objects/time/Year.ts +0 -27
- package/tests/errors/BaseError.spec.ts +0 -63
- package/tests/errors/DomainError.spec.ts +0 -52
- package/tests/patterns/Assert.spec.ts +0 -29
- package/tests/setup.jest.ts +0 -2
- package/tests/value-objects/Color.spec.ts +0 -214
- package/tests/value-objects/Email.spec.ts +0 -141
- package/tests/value-objects/Enum.spec.ts +0 -293
- package/tests/value-objects/Integer.spec.ts +0 -38
- package/tests/value-objects/NullObject.spec.ts +0 -55
- package/tests/value-objects/NumberValueObject.spec.ts +0 -446
- package/tests/value-objects/PositiveNumber.spec.ts +0 -274
- package/tests/value-objects/StringValueObject.spec.ts +0 -135
- package/tests/value-objects/coordinates/Coordinates.spec.ts +0 -90
- package/tests/value-objects/coordinates/Latitude.spec.ts +0 -24
- package/tests/value-objects/coordinates/Longitude.spec.ts +0 -24
- package/tests/value-objects/hashes/Hashes.spec.ts +0 -139
- package/tests/value-objects/hashes/MD5Hash.spec.ts +0 -187
- package/tests/value-objects/hashes/SHA256Hash.spec.ts +0 -220
- package/tests/value-objects/hashes/SHA512Hash.spec.ts +0 -220
- package/tests/value-objects/ids/ShortId.spec.ts +0 -34
- package/tests/value-objects/ids/UUID.spec.ts +0 -37
- package/tests/value-objects/time/CalendarDay.spec.ts +0 -182
- package/tests/value-objects/time/Day.spec.ts +0 -29
- package/tests/value-objects/time/DayOfWeek.spec.ts +0 -71
- package/tests/value-objects/time/Duration.spec.ts +0 -278
- package/tests/value-objects/time/Hour.spec.ts +0 -197
- package/tests/value-objects/time/MonthOfYear.spec.ts +0 -111
- package/tests/value-objects/time/Timestamp.spec.ts +0 -497
- package/tests/value-objects/time/TimestampInterval.spec.ts +0 -383
- package/tests/value-objects/time/Year.spec.ts +0 -48
- package/tsconfig.jest.json +0 -33
- package/tsconfig.json +0 -42
|
@@ -1,497 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Timestamp,
|
|
3
|
-
Year,
|
|
4
|
-
Month,
|
|
5
|
-
Day,
|
|
6
|
-
Duration,
|
|
7
|
-
CalendarDay,
|
|
8
|
-
MonthOfYear,
|
|
9
|
-
} from '../../../src';
|
|
10
|
-
|
|
11
|
-
describe('Timestamp', () => {
|
|
12
|
-
describe('constructor', () => {
|
|
13
|
-
it('should create a Timestamp with a Date value', () => {
|
|
14
|
-
expect(new Timestamp(new Date())).toBeInstanceOf(Timestamp);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('should create a Timestamp with a number value', () => {
|
|
18
|
-
expect(new Timestamp(1666094980)).toBeInstanceOf(Timestamp);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('should create a Timestamp with Timestamp value', () => {
|
|
22
|
-
expect(new Timestamp(new Timestamp(1666094980))).toBeInstanceOf(
|
|
23
|
-
Timestamp,
|
|
24
|
-
);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('should create a Timestamp with string value', () => {
|
|
28
|
-
expect(new Timestamp('2020-01-01')).toBeInstanceOf(Timestamp);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('should create a Timestamp with a empty value', () => {
|
|
32
|
-
expect(new Timestamp()).toBeInstanceOf(Timestamp);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
describe('static new', () => {
|
|
37
|
-
it('should create a Timestamp with a Date value', () => {
|
|
38
|
-
expect(Timestamp.new(1666094980)).toBeInstanceOf(Timestamp);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('should create a Timestamp with a number value', () => {
|
|
42
|
-
expect(Timestamp.new(new Date())).toBeInstanceOf(Timestamp);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('should create a Timestamp with Timestamp value', () => {
|
|
46
|
-
expect(Timestamp.new(new Timestamp())).toBeInstanceOf(Timestamp);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
describe('static now', () => {
|
|
51
|
-
it('should create a Timestamp with a Date value', () => {
|
|
52
|
-
expect(Timestamp.now()).toBeInstanceOf(Timestamp);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
describe('fromSeconds', () => {
|
|
57
|
-
it('should create a Timestamp with a Date value', () => {
|
|
58
|
-
expect(Timestamp.fromSeconds(1666094)).toBeInstanceOf(Timestamp);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
describe('toExactHour', () => {
|
|
63
|
-
it('should convert a non-exact hour date to have exact hour', () => {
|
|
64
|
-
const timestamp = new Timestamp('2024-05-06T09:35:53.205Z');
|
|
65
|
-
const newTimestamp = timestamp.toExactHour();
|
|
66
|
-
|
|
67
|
-
expect(newTimestamp.getYear()).toEqual(new Year(2024));
|
|
68
|
-
expect(newTimestamp.getMonth()).toEqual(Month.MAY);
|
|
69
|
-
expect(newTimestamp.getDay()).toEqual(new Day(6));
|
|
70
|
-
expect(newTimestamp.getHours()).toEqual(9);
|
|
71
|
-
expect(newTimestamp.getMinutes()).toEqual(0);
|
|
72
|
-
expect(newTimestamp.getSeconds()).toEqual(0);
|
|
73
|
-
expect(newTimestamp.getMilliseconds()).toEqual(0);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('should convert a non-exact hour date to have exact hour with return value', () => {
|
|
77
|
-
const timestamp = new Timestamp('2024-05-06T09:35:53.205Z');
|
|
78
|
-
const resultTimestamp = timestamp.toExactHour();
|
|
79
|
-
|
|
80
|
-
expect(resultTimestamp.getYear()).toEqual(new Year(2024));
|
|
81
|
-
expect(resultTimestamp.getMonth()).toEqual(Month.MAY);
|
|
82
|
-
expect(resultTimestamp.getDay()).toEqual(new Day(6));
|
|
83
|
-
expect(resultTimestamp.getHours()).toEqual(9);
|
|
84
|
-
expect(resultTimestamp.getMinutes()).toEqual(0);
|
|
85
|
-
expect(resultTimestamp.getSeconds()).toEqual(0);
|
|
86
|
-
expect(resultTimestamp.getMilliseconds()).toEqual(0);
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
describe('toMilliseconds', () => {
|
|
91
|
-
it('should return a number', () => {
|
|
92
|
-
expect(Timestamp.now().toMilliseconds()).toBeNumber();
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
describe('toSeconds', () => {
|
|
97
|
-
it('should return a number', () => {
|
|
98
|
-
expect(Timestamp.now().toSeconds()).toBeNumber();
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
describe('toDate', () => {
|
|
103
|
-
it('should return a Date', () => {
|
|
104
|
-
expect(Timestamp.now().toDate()).toBeInstanceOf(Date);
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
describe('toString', () => {
|
|
109
|
-
it('should return a string', () => {
|
|
110
|
-
const timestamp = Timestamp.now();
|
|
111
|
-
expect(timestamp.toString()).toEqual(`${timestamp.valueOf()}`);
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
describe('valueOf', () => {
|
|
116
|
-
it('should return a number', () => {
|
|
117
|
-
expect(Timestamp.now().valueOf()).toBeNumber();
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
describe('isEqual', () => {
|
|
122
|
-
it('should return true when value is equal to other', () => {
|
|
123
|
-
const now = Timestamp.now();
|
|
124
|
-
expect(now.isEqual(new Timestamp(now.valueOf()))).toBeTrue();
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
describe('isBefore', () => {
|
|
129
|
-
it('should return true when value is before other', () => {
|
|
130
|
-
expect(Timestamp.now().isBefore(Timestamp.now().addDays(1))).toBeTrue();
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
describe('isAfter', () => {
|
|
135
|
-
it('should return true when value is after other', () => {
|
|
136
|
-
expect(Timestamp.now().isAfter(Timestamp.now())).toBeFalse();
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
describe('isBeforeOrEqual', () => {
|
|
141
|
-
it('should return true when value is before or equal to other', () => {
|
|
142
|
-
const tomorrow = Timestamp.now().addDays(1);
|
|
143
|
-
expect(Timestamp.now().isBeforeOrEqual(tomorrow)).toBeTrue();
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
describe('isAfterOrEqual', () => {
|
|
148
|
-
it('should return true when value is after or equal to other', () => {
|
|
149
|
-
const yesterday = Timestamp.now().addDays(-1);
|
|
150
|
-
expect(Timestamp.now().isAfterOrEqual(yesterday)).toBeTrue();
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
describe('addMilliseconds', () => {
|
|
155
|
-
it('should add Milliseconds', () => {
|
|
156
|
-
const timestamp = Timestamp.now();
|
|
157
|
-
const copy = Timestamp.new(timestamp);
|
|
158
|
-
expect(timestamp.addMilliseconds(1)).toStrictEqual(
|
|
159
|
-
new Timestamp(copy.valueOf() + 1),
|
|
160
|
-
);
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
describe('addSeconds', () => {
|
|
165
|
-
it('should add seconds', () => {
|
|
166
|
-
const timestamp = Timestamp.now();
|
|
167
|
-
const copy = Timestamp.new(timestamp);
|
|
168
|
-
expect(timestamp.addSeconds(1).isAfter(copy)).toBeTrue();
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
describe('addMinutes', () => {
|
|
173
|
-
it('should add minutes', () => {
|
|
174
|
-
const timestamp = Timestamp.now();
|
|
175
|
-
const copy = Timestamp.new(timestamp);
|
|
176
|
-
expect(timestamp.addMinutes(1).isAfter(copy)).toBeTrue();
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
describe('addHours', () => {
|
|
181
|
-
it('should add hours', () => {
|
|
182
|
-
const timestamp = Timestamp.now();
|
|
183
|
-
const copy = Timestamp.new(timestamp);
|
|
184
|
-
expect(timestamp.addHours(1).isAfter(copy)).toBeTrue();
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
describe('addDays', () => {
|
|
189
|
-
it('should add days', () => {
|
|
190
|
-
const timestamp = Timestamp.now();
|
|
191
|
-
const copy = Timestamp.new(timestamp);
|
|
192
|
-
expect(timestamp.addDays(1).isAfter(copy)).toBeTrue();
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
describe('addWeeks', () => {
|
|
197
|
-
it('should add weeks', () => {
|
|
198
|
-
const timestamp = Timestamp.now();
|
|
199
|
-
const copy = Timestamp.new(timestamp);
|
|
200
|
-
expect(timestamp.addWeeks(1).isAfter(copy)).toBeTrue();
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
describe('addMonths', () => {
|
|
205
|
-
it('should add months', () => {
|
|
206
|
-
const timestamp = Timestamp.now();
|
|
207
|
-
const copy = Timestamp.new(timestamp);
|
|
208
|
-
expect(timestamp.addMonths(1).isAfter(copy)).toBeTrue();
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
describe('addYears', () => {
|
|
213
|
-
it('should add years', () => {
|
|
214
|
-
const timestamp = Timestamp.now();
|
|
215
|
-
const copy = Timestamp.new(timestamp);
|
|
216
|
-
expect(timestamp.addYears(1).isAfter(copy)).toBeTrue();
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
describe('getDay', () => {
|
|
221
|
-
it('should return a value object', () => {
|
|
222
|
-
expect(Timestamp.now().getDay()).toBeObject();
|
|
223
|
-
});
|
|
224
|
-
it('should return a number in the correct timezone', () => {
|
|
225
|
-
expect(
|
|
226
|
-
Timestamp.new(new Date('Sun Dec 31 2023 23:04:36 GMT-0100')).getDay(),
|
|
227
|
-
).toStrictEqual(new Day(1));
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
describe('getMonth', () => {
|
|
232
|
-
it('should return a Month', () => {
|
|
233
|
-
expect(new Timestamp('2025-01-01').getMonth()).toStrictEqual(
|
|
234
|
-
Month.JANUARY,
|
|
235
|
-
);
|
|
236
|
-
});
|
|
237
|
-
it('should return a number in the correct timezone', () => {
|
|
238
|
-
expect(
|
|
239
|
-
Timestamp.new(new Date('Sun Dec 31 2023 23:04:36 GMT-0100')).getDay(),
|
|
240
|
-
).toStrictEqual(new Day(1));
|
|
241
|
-
});
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
describe('getYear', () => {
|
|
245
|
-
it('should return a Year', () => {
|
|
246
|
-
expect(new Timestamp('2025-01-01').getYear()).toStrictEqual(
|
|
247
|
-
new Year(2025),
|
|
248
|
-
);
|
|
249
|
-
});
|
|
250
|
-
it('should return a Year in the correct timezone', () => {
|
|
251
|
-
expect(
|
|
252
|
-
Timestamp.new(new Date('Sun Dec 31 2023 23:04:36 GMT-0100')).getYear(),
|
|
253
|
-
).toStrictEqual(new Year(2024));
|
|
254
|
-
});
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
describe('getHours', () => {
|
|
258
|
-
it('should return a number', () => {
|
|
259
|
-
expect(Timestamp.now().getHours()).toBeNumber();
|
|
260
|
-
});
|
|
261
|
-
it('should return a number in the correct timezone', () => {
|
|
262
|
-
expect(
|
|
263
|
-
Timestamp.new(new Date('Sun Dec 31 2023 23:04:36 GMT-0100')).getHours(),
|
|
264
|
-
).toBe(0);
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
describe('getMinutes', () => {
|
|
269
|
-
it('should return a number', () => {
|
|
270
|
-
expect(Timestamp.now().getMinutes()).toBeNumber();
|
|
271
|
-
});
|
|
272
|
-
it('should return a number in the correct timezone', () => {
|
|
273
|
-
expect(
|
|
274
|
-
Timestamp.new(
|
|
275
|
-
new Date('Sun Dec 31 2023 23:04:36 GMT-0100'),
|
|
276
|
-
).getMinutes(),
|
|
277
|
-
).toBe(4);
|
|
278
|
-
});
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
describe('getSeconds', () => {
|
|
282
|
-
it('should return a number', () => {
|
|
283
|
-
expect(Timestamp.now().getSeconds()).toBeNumber();
|
|
284
|
-
});
|
|
285
|
-
it('should return a number in the correct timezone', () => {
|
|
286
|
-
expect(
|
|
287
|
-
Timestamp.new(
|
|
288
|
-
new Date('Sun Dec 31 2023 23:04:36 GMT-0100'),
|
|
289
|
-
).getSeconds(),
|
|
290
|
-
).toBe(36);
|
|
291
|
-
});
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
describe('getMilliseconds', () => {
|
|
295
|
-
it('should return a number', () => {
|
|
296
|
-
expect(Timestamp.now().getMilliseconds()).toBeNumber();
|
|
297
|
-
});
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
describe('getDayOfWeek', () => {
|
|
301
|
-
it('should return a number', () => {
|
|
302
|
-
expect(Timestamp.now().getDayOfWeek()).toBeNumber();
|
|
303
|
-
});
|
|
304
|
-
it('should return a number in the correct timezone', () => {
|
|
305
|
-
expect(
|
|
306
|
-
Timestamp.new(
|
|
307
|
-
new Date('Sun Dec 31 2023 23:04:36 GMT-0100'),
|
|
308
|
-
).getDayOfWeek(),
|
|
309
|
-
).toBe(1);
|
|
310
|
-
});
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
describe('isSameDay', () => {
|
|
314
|
-
it('should return true for Timestamps on the same day', () => {
|
|
315
|
-
const timestamp1 = new Timestamp('2024-05-06T09:35:53.205Z');
|
|
316
|
-
const timestamp2 = new Timestamp('2024-05-06T23:59:59.999Z');
|
|
317
|
-
expect(timestamp1.isSameDay(timestamp2)).toBeTrue();
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
it('should return false for Timestamps on different days', () => {
|
|
321
|
-
const timestamp1 = new Timestamp('2024-05-06T09:35:53.205Z');
|
|
322
|
-
const timestamp2 = new Timestamp('2024-05-07T00:00:00.000Z');
|
|
323
|
-
expect(timestamp1.isSameDay(timestamp2)).toBeFalse();
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
it('should return true for Timestamps on the same day in different timezones', () => {
|
|
327
|
-
const timestamp1 = new Timestamp('2024-05-06T23:59:59.999Z');
|
|
328
|
-
const timestamp2 = new Timestamp('2024-05-06T00:00:00.000Z');
|
|
329
|
-
expect(timestamp1.isSameDay(timestamp2)).toBeTrue();
|
|
330
|
-
});
|
|
331
|
-
|
|
332
|
-
it('should return false for Timestamps on the same day but different months', () => {
|
|
333
|
-
const timestamp1 = new Timestamp('2024-05-06T09:35:53.205Z');
|
|
334
|
-
const timestamp2 = new Timestamp('2024-06-06T09:35:53.205Z');
|
|
335
|
-
expect(timestamp1.isSameDay(timestamp2)).toBeFalse();
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
it('should return false for Timestamps on the same day but different years', () => {
|
|
339
|
-
const timestamp1 = new Timestamp('2024-05-06T09:35:53.205Z');
|
|
340
|
-
const timestamp2 = new Timestamp('2025-05-06T09:35:53.205Z');
|
|
341
|
-
expect(timestamp1.isSameDay(timestamp2)).toBeFalse();
|
|
342
|
-
});
|
|
343
|
-
});
|
|
344
|
-
describe('addDuration', () => {
|
|
345
|
-
it('should add a duration to the timestamp', () => {
|
|
346
|
-
const timestamp = new Timestamp('2024-05-06T09:35:53.205Z');
|
|
347
|
-
const duration = Duration.fromMinutes(1);
|
|
348
|
-
const newTimestamp = timestamp.addDuration(duration);
|
|
349
|
-
|
|
350
|
-
expect(newTimestamp).toEqual(
|
|
351
|
-
new Timestamp(
|
|
352
|
-
timestamp.valueOf() + duration.getTotalMilliseconds().valueOf(),
|
|
353
|
-
),
|
|
354
|
-
);
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
it('should return a new Timestamp instance', () => {
|
|
358
|
-
const timestamp = new Timestamp('2024-05-06T09:35:53.205Z');
|
|
359
|
-
const duration = Duration.fromMinutes(1);
|
|
360
|
-
const newTimestamp = timestamp.addDuration(duration);
|
|
361
|
-
|
|
362
|
-
expect(newTimestamp).toBeInstanceOf(Timestamp);
|
|
363
|
-
expect(newTimestamp).not.toBe(timestamp);
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
it('should handle a duration of 0 milliseconds', () => {
|
|
367
|
-
const timestamp = new Timestamp('2024-05-06T09:35:53.205Z');
|
|
368
|
-
const duration = Duration.fromHours(0);
|
|
369
|
-
const newTimestamp = timestamp.addDuration(duration);
|
|
370
|
-
|
|
371
|
-
expect(newTimestamp.toMilliseconds()).toEqual(timestamp.toMilliseconds());
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
it('should handle a negative duration', () => {
|
|
375
|
-
const timestamp = new Timestamp('2024-05-06T09:35:53.205Z');
|
|
376
|
-
const duration = Duration.fromMinutes(-1);
|
|
377
|
-
const newTimestamp = timestamp.addDuration(duration);
|
|
378
|
-
|
|
379
|
-
expect(newTimestamp.toMilliseconds()).toEqual(
|
|
380
|
-
timestamp.toMilliseconds() - 60000,
|
|
381
|
-
);
|
|
382
|
-
});
|
|
383
|
-
});
|
|
384
|
-
describe('isSameMonth', () => {
|
|
385
|
-
it('should return true for Timestamps in the same month and year', () => {
|
|
386
|
-
const timestamp1 = new Timestamp('2024-05-06T09:35:53.205Z');
|
|
387
|
-
const timestamp2 = new Timestamp('2024-05-31T23:59:59.999Z');
|
|
388
|
-
expect(timestamp1.isSameMonth(timestamp2)).toBeTrue();
|
|
389
|
-
});
|
|
390
|
-
|
|
391
|
-
it('should return false for Timestamps in the same month but different years', () => {
|
|
392
|
-
const timestamp1 = new Timestamp('2024-05-06T09:35:53.205Z');
|
|
393
|
-
const timestamp2 = new Timestamp('2025-05-06T09:35:53.205Z');
|
|
394
|
-
expect(timestamp1.isSameMonth(timestamp2)).toBeFalse();
|
|
395
|
-
});
|
|
396
|
-
|
|
397
|
-
it('should return false for Timestamps in different months of the same year', () => {
|
|
398
|
-
const timestamp1 = new Timestamp('2024-05-06T09:35:53.205Z');
|
|
399
|
-
const timestamp2 = new Timestamp('2024-06-06T09:35:53.205Z');
|
|
400
|
-
expect(timestamp1.isSameMonth(timestamp2)).toBeFalse();
|
|
401
|
-
});
|
|
402
|
-
|
|
403
|
-
it('should return false for Timestamps in different months and years', () => {
|
|
404
|
-
const timestamp1 = new Timestamp('2024-05-06T09:35:53.205Z');
|
|
405
|
-
const timestamp2 = new Timestamp('2025-06-06T09:35:53.205Z');
|
|
406
|
-
expect(timestamp1.isSameMonth(timestamp2)).toBeFalse();
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
it('should return true for Timestamps in the same month regardless of time', () => {
|
|
410
|
-
const timestamp1 = new Timestamp('2024-05-01T00:00:00.000Z');
|
|
411
|
-
const timestamp2 = new Timestamp('2024-05-31T23:59:59.999Z');
|
|
412
|
-
expect(timestamp1.isSameMonth(timestamp2)).toBeTrue();
|
|
413
|
-
});
|
|
414
|
-
});
|
|
415
|
-
describe('isSameYear', () => {
|
|
416
|
-
it('should return true for Timestamps in the same year', () => {
|
|
417
|
-
const timestamp1 = new Timestamp('2024-05-06T09:35:53.205Z');
|
|
418
|
-
const timestamp2 = new Timestamp('2024-12-31T23:59:59.999Z');
|
|
419
|
-
expect(timestamp1.isSameYear(timestamp2)).toBeTrue();
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
it('should return false for Timestamps in different years', () => {
|
|
423
|
-
const timestamp1 = new Timestamp('2024-05-06T09:35:53.205Z');
|
|
424
|
-
const timestamp2 = new Timestamp('2025-05-06T09:35:53.205Z');
|
|
425
|
-
expect(timestamp1.isSameYear(timestamp2)).toBeFalse();
|
|
426
|
-
});
|
|
427
|
-
|
|
428
|
-
it('should return true for Timestamps in the same year regardless of month or day', () => {
|
|
429
|
-
const timestamp1 = new Timestamp('2024-01-01T00:00:00.000Z');
|
|
430
|
-
const timestamp2 = new Timestamp('2024-12-31T23:59:59.999Z');
|
|
431
|
-
expect(timestamp1.isSameYear(timestamp2)).toBeTrue();
|
|
432
|
-
});
|
|
433
|
-
|
|
434
|
-
it('should return false for Timestamps in the same month but different years', () => {
|
|
435
|
-
const timestamp1 = new Timestamp('2024-05-06T09:35:53.205Z');
|
|
436
|
-
const timestamp2 = new Timestamp('2025-05-06T09:35:53.205Z');
|
|
437
|
-
expect(timestamp1.isSameYear(timestamp2)).toBeFalse();
|
|
438
|
-
});
|
|
439
|
-
|
|
440
|
-
it('should return true for Timestamps in the same year with different timezones', () => {
|
|
441
|
-
const timestamp1 = new Timestamp('2024-05-06T23:59:59.999Z');
|
|
442
|
-
const timestamp2 = new Timestamp('2024-05-06T00:00:00.000Z');
|
|
443
|
-
expect(timestamp1.isSameYear(timestamp2)).toBeTrue();
|
|
444
|
-
});
|
|
445
|
-
});
|
|
446
|
-
describe('getCalendarDay', () => {
|
|
447
|
-
it('should return a CalendarDay instance', () => {
|
|
448
|
-
const today = new CalendarDay();
|
|
449
|
-
const timestamp = Timestamp.now();
|
|
450
|
-
const calendarDay = timestamp.getCalendarDay();
|
|
451
|
-
expect(calendarDay).toStrictEqual(today);
|
|
452
|
-
});
|
|
453
|
-
|
|
454
|
-
it('should return a CalendarDay with the correct date', () => {
|
|
455
|
-
const timestamp = new Timestamp('2024-05-06T09:35:53.205Z');
|
|
456
|
-
const calendarDay = timestamp.getCalendarDay();
|
|
457
|
-
expect(calendarDay).toStrictEqual(new CalendarDay('2024-05-06'));
|
|
458
|
-
});
|
|
459
|
-
});
|
|
460
|
-
describe('getMonthOfYear', () => {
|
|
461
|
-
it('should return a MonthOfYear instance', () => {
|
|
462
|
-
const timestamp = new Timestamp('2024-05-06T09:35:53.205Z');
|
|
463
|
-
const monthOfYear = timestamp.getMonthOfYear();
|
|
464
|
-
expect(monthOfYear).toStrictEqual(
|
|
465
|
-
new MonthOfYear(Month.MAY, new Year(2024)),
|
|
466
|
-
);
|
|
467
|
-
});
|
|
468
|
-
|
|
469
|
-
it('should return the correct month and year', () => {
|
|
470
|
-
const timestamp = new Timestamp('2024-05-06T09:35:53.205Z');
|
|
471
|
-
const monthOfYear = timestamp.getMonthOfYear();
|
|
472
|
-
expect(monthOfYear.getMonth()).toStrictEqual(Month.MAY);
|
|
473
|
-
expect(monthOfYear.getYear()).toStrictEqual(new Year(2024));
|
|
474
|
-
});
|
|
475
|
-
|
|
476
|
-
it('should handle timestamps in different timezones correctly', () => {
|
|
477
|
-
const timestamp = new Timestamp('2024-12-31T23:59:59.999Z');
|
|
478
|
-
const monthOfYear = timestamp.getMonthOfYear();
|
|
479
|
-
expect(monthOfYear.getMonth()).toStrictEqual(Month.DECEMBER);
|
|
480
|
-
expect(monthOfYear.getYear()).toStrictEqual(new Year(2024));
|
|
481
|
-
});
|
|
482
|
-
|
|
483
|
-
it('should handle edge cases at the start of the year', () => {
|
|
484
|
-
const timestamp = new Timestamp('2024-01-01T00:00:00.000Z');
|
|
485
|
-
const monthOfYear = timestamp.getMonthOfYear();
|
|
486
|
-
expect(monthOfYear.getMonth()).toStrictEqual(Month.JANUARY);
|
|
487
|
-
expect(monthOfYear.getYear()).toStrictEqual(new Year(2024));
|
|
488
|
-
});
|
|
489
|
-
|
|
490
|
-
it('should handle edge cases at the end of the year', () => {
|
|
491
|
-
const timestamp = new Timestamp('2024-12-31T23:59:59.999Z');
|
|
492
|
-
const monthOfYear = timestamp.getMonthOfYear();
|
|
493
|
-
expect(monthOfYear.getMonth()).toStrictEqual(Month.DECEMBER);
|
|
494
|
-
expect(monthOfYear.getYear()).toStrictEqual(new Year(2024));
|
|
495
|
-
});
|
|
496
|
-
});
|
|
497
|
-
});
|