Skip to content
GitHub Actions / Test results (Node.js: 20) succeeded Apr 15, 2024 in 1s

250 passed, 0 failed and 0 skipped

Tests passed successfully

✅ jest-junit.xml

250 tests were completed in 14s with 250 passed, 0 failed and 0 skipped.

Test suite Passed Failed Skipped Time
tests/unit/decorators/virtual-column.decorator.test.ts 3✅ 189ms
tests/unit/exceptions/bad-request.exception.test.ts 3✅ 170ms
tests/unit/exceptions/conflict.exception.test.ts 3✅ 170ms
tests/unit/exceptions/forbidden.exception.test.ts 3✅ 173ms
tests/unit/exceptions/http.exception.test.ts 3✅ 174ms
tests/unit/exceptions/internal-server-error.exception.test.ts 3✅ 170ms
tests/unit/exceptions/not-found.exception.test.ts 3✅ 172ms
tests/unit/exceptions/refresh-token-expired.exception.test.ts 1✅ 166ms
tests/unit/exceptions/refresh-token-verify.exception.test.ts 1✅ 165ms
tests/unit/exceptions/token-expired.exception.test.ts 1✅ 165ms
tests/unit/exceptions/token-malformed.exception.test.ts 1✅ 165ms
tests/unit/exceptions/token-not-provided.exception.test.ts 1✅ 167ms
tests/unit/exceptions/token-verify.exception.test.ts 1✅ 168ms
tests/unit/exceptions/unprocessable-entity.exception.test.ts 3✅ 172ms
tests/unit/middlewares/async.middleware.test.ts 3✅ 439ms
tests/unit/middlewares/auth.middleware.test.ts 5✅ 657ms
tests/unit/middlewares/error.middleware.test.ts 2✅ 443ms
tests/unit/middlewares/user-session.middleware.test.ts 3✅ 474ms
tests/unit/middlewares/validate.middleware.test.ts 6✅ 2s
tests/unit/providers/apple.service.test.ts 3✅ 397ms
tests/unit/providers/email.service.test.ts 3✅ 418ms
tests/unit/providers/facebook.service.test.ts 3✅ 364ms
tests/unit/providers/github.service.test.ts 3✅ 337ms
tests/unit/providers/google.service.test.ts 3✅ 324ms
tests/unit/providers/token.service.test.ts 6✅ 363ms
tests/unit/utils/common.util.test.ts 16✅ 190ms
tests/unit/utils/date.util.test.ts 60✅ 3s
tests/unit/utils/hash.util.test.ts 15✅ 392ms
tests/unit/utils/ip.util.test.ts 7✅ 198ms
tests/unit/utils/joi.util.test.ts 4✅ 228ms
tests/unit/utils/mapping.util.test.ts 4✅ 175ms
tests/unit/utils/number.util.test.ts 14✅ 185ms
tests/unit/utils/queue.util.test.ts 4✅ 204ms
tests/unit/utils/request.util.test.ts 6✅ 266ms
tests/unit/utils/string.util.test.ts 29✅ 256ms
tests/unit/utils/template.util.test.ts 3✅ 234ms
tests/unit/utils/url.util.test.ts 8✅ 327ms
tests/unit/utils/user-agent.util.test.ts 10✅ 179ms

✅ tests/unit/decorators/virtual-column.decorator.test.ts

VirtualColumn
  ✅ should define metadata for the target with the property key as the name when no name is provided
  ✅ should define metadata for the target with the provided name
  ✅ should not overwrite existing metadata for the target

✅ tests/unit/exceptions/bad-request.exception.test.ts

BadRequestException
  ✅ should create an instance with default message when no message is provided
  ✅ should create an instance with the provided message
  ✅ should create an instance with the provided message object

✅ tests/unit/exceptions/conflict.exception.test.ts

ConflictException
  ✅ should create an instance with default message when no message is provided
  ✅ should create an instance with the provided message
  ✅ should create an instance with the provided message object

✅ tests/unit/exceptions/forbidden.exception.test.ts

ForbiddenException
  ✅ should create an instance with default message when no message is provided
  ✅ should create an instance with the provided message
  ✅ should create an instance with the provided message object

✅ tests/unit/exceptions/http.exception.test.ts

HttpException
  ✅ should create an instance with default values when no parameters are provided
  ✅ should create an instance with the provided parameters
  ✅ should create an instance with the provided message object

✅ tests/unit/exceptions/internal-server-error.exception.test.ts

InternalServerErrorException
  ✅ should create an instance with default message when no message is provided
  ✅ should create an instance with the provided message
  ✅ should create an instance with the provided message object

✅ tests/unit/exceptions/not-found.exception.test.ts

NotFoundException
  ✅ should create an instance with default message when no message is provided
  ✅ should create an instance with the provided message
  ✅ should create an instance with the provided message object

✅ tests/unit/exceptions/refresh-token-expired.exception.test.ts

RefreshTokenExpiredException
  ✅ should create an instance with default message

✅ tests/unit/exceptions/refresh-token-verify.exception.test.ts

RefreshTokenVerifyException
  ✅ should create an instance with default message

✅ tests/unit/exceptions/token-expired.exception.test.ts

TokenExpiredException
  ✅ should create an instance with default message

✅ tests/unit/exceptions/token-malformed.exception.test.ts

TokenMalformedException
  ✅ should create an instance with default message

✅ tests/unit/exceptions/token-not-provided.exception.test.ts

TokenNotProvidedException
  ✅ should create an instance with default message

✅ tests/unit/exceptions/token-verify.exception.test.ts

TokenVerifyException
  ✅ should create an instance with default message

✅ tests/unit/exceptions/unprocessable-entity.exception.test.ts

UnprocessableEntityException
  ✅ should create an instance with default message when no message is provided
  ✅ should create an instance with the provided message
  ✅ should create an instance with the provided message object

✅ tests/unit/middlewares/async.middleware.test.ts

AsyncMiddleware
  ✅ should handle the request and response
  ✅ should call next function when an error is thrown
  ✅ should call next function when a notFoundException is thrown

✅ tests/unit/middlewares/auth.middleware.test.ts

AuthMiddleware
  ✅ should set user to anonymous role if no token is provided
  ✅ should set user to the payload of the verified token if token is provided
  ✅ should throw an error if token is not in the correct format
  ✅ should call next function with error if token verification fails
  ✅ should throw an error if token is expired

✅ tests/unit/middlewares/error.middleware.test.ts

ErrorMiddleware
  ✅ should respond with the error if it has a messageCode and statusCode
  ✅ should respond with InternalServerErrorException if the error does not have a messageCode and statusCode

✅ tests/unit/middlewares/user-session.middleware.test.ts

UserSessionMiddleware
  ✅ should set userSession on the request
  ✅ should set userSession with default values if no headers are provided
  ✅ should set userSession with default values if user-agent and origin headers are undefined

✅ tests/unit/middlewares/validate.middleware.test.ts

ValidateMiddleware › schema.params
  ✅ should call next function if validation passes
  ✅ should respond with UnprocessableEntityException if validation fails
ValidateMiddleware › schema.query
  ✅ should call next function if validation passes
  ✅ should respond with UnprocessableEntityException if validation fails
ValidateMiddleware › schema.body
  ✅ should call next function if validation passes
  ✅ should respond with UnprocessableEntityException if validation fails

✅ tests/unit/providers/apple.service.test.ts

AppleService › getPayload
  ✅ should return the payload if the token is valid
  ✅ should return the payload without email if the token is valid and no email is provided
  ✅ should throw an error if the token is invalid

✅ tests/unit/providers/email.service.test.ts

EmailService › sendEmail
  ✅ should send an email with the provided options
  ✅ should send an email with a template if a template path is provided
  ✅ should throw an error if sending the email fails

✅ tests/unit/providers/facebook.service.test.ts

FacebookService › getPayload
  ✅ should return the payload if the token is valid
  ✅ should return the payload without email if the token is valid and no email is provided
  ✅ should throw an error if the token is invalid

✅ tests/unit/providers/github.service.test.ts

GitHubService › getPayload
  ✅ should return the payload if the token is valid
  ✅ should return the payload without email and name if the token is valid and no email and name are provided
  ✅ should throw an error if the token is invalid

✅ tests/unit/providers/google.service.test.ts

GoogleService › getPayload
  ✅ should return the payload if the token is valid
  ✅ should return the payload without email and name if the token is valid and no email and name are provided
  ✅ should throw an error if the token is invalid

✅ tests/unit/providers/token.service.test.ts

TokenService › signJwt
  ✅ signs a valid JWT
TokenService › verify
  ✅ verifies a JWT
  ✅ verifies a JWT and gets data
TokenService › decode
  ✅ decodes a JWT
  ✅ decodes a JWT and gets data
  ✅ decodes a JWT and with a wrong secret

✅ tests/unit/utils/common.util.test.ts

CommonUtil › isEmpty
  ✅ should return true for null or undefined
  ✅ should return true for an empty string
  ✅ should return true for an empty array
  ✅ should return true for an empty object
  ✅ should return false for a non-empty string
  ✅ should return false for a non-empty array
  ✅ should return false for a non-empty object
  ✅ should return false for a number
  ✅ should return false for a boolean
CommonUtil › isNullOrUndefined
  ✅ should return true for null
  ✅ should return true for undefined
  ✅ should return false for an empty string
  ✅ should return false for a number
  ✅ should return false for a boolean
  ✅ should return false for an empty array
  ✅ should return false for an empty object

✅ tests/unit/utils/date.util.test.ts

DateUtil › addMillisecondToDate
  ✅ should add the specified number of milliseconds to the date
  ✅ should return the same date if no milliseconds are specified
  ✅ should use the current date if no date is specified
  ✅ should handle negative milliseconds
  ✅ should handle date strings
  ✅ should handle date numbers
DateUtil › addMonths
  ✅ should add the specified number of months to the date
  ✅ should return the same date if no months are specified
  ✅ should use the current date if no date is specified
  ✅ should handle negative months
  ✅ should handle date strings
  ✅ should handle date numbers
DateUtil › endOfDay
  ✅ should return the end of the day for the specified date
  ✅ should return the end of the current day if no date is specified
  ✅ should handle date strings
  ✅ should handle date numbers
DateUtil › startOfDay
  ✅ should return the start of the day for the specified date
  ✅ should return the start of the current day if no date is specified
  ✅ should handle date strings
  ✅ should handle date numbers
DateUtil › isBetweenDay
  ✅ should return true if the current date is between the start and end dates
  ✅ should return true if the current date is the same as the start or end date
  ✅ should return false if the current date is before the start date or after the end date
  ✅ should use the current date if no current date is specified
DateUtil › isSameDay
  ✅ should return true if the two dates are on the same day
  ✅ should return false if the two dates are not on the same day
  ✅ should return false if either date is invalid
  ✅ should handle date strings
  ✅ should handle date numbers
DateUtil › isSameOrBeforeDay
  ✅ should return true if the first date is the same as the second date
  ✅ should return true if the first date is before the second date
  ✅ should return false if the first date is after the second date
  ✅ should handle date strings
  ✅ should handle date numbers
DateUtil › parseISO
  ✅ should parse a valid ISO date string
  ✅ should return the same date if a date object is provided
  ✅ should throw an error if an invalid date string is provided
  ✅ should throw an error if no date is provided
DateUtil › parseStringToMs
  ✅ should parse a valid time 2 days/d to milliseconds
  ✅ should return 0 for an empty string
  ✅ should throw an error for an invalid time string
  ✅ should parse a valid time 3h to milliseconds
DateUtil › timeZoneToUTC
  ✅ should convert a date in a specific timezone to UTC
  ✅ should throw an error if an invalid date is provided
  ✅ should throw an error if an invalid timezone is provided
DateUtil › toFormat
  ✅ should format a date to the default format
  ✅ should format a date to a specified format
  ✅ should handle date objects
  ✅ should throw an error if an invalid date is provided
  ✅ should throw an error if an invalid format is provided
DateUtil › toFormatUTC
  ✅ should format a local date to the default format in UTC
  ✅ should format a local date to a specified format in UTC
  ✅ should format a local date to a specified format in UTC
  ✅ should handle date objects
  ✅ should throw an error if an invalid date is provided
  ✅ should throw an error if an invalid format is provided
DateUtil › toUnix
  ✅ should convert a valid ISO date string to Unix time
  ✅ should convert a date object to Unix time
  ✅ should throw an error if an invalid date is provided
  ✅ should handle date numbers

✅ tests/unit/utils/hash.util.test.ts

HashUtil › generateHashFromString
  ✅ should return a hash when a string is provided
  ✅ should return a different hash when a different string is provided
  ✅ should return the same hash when the same string is provided
HashUtil › generateRandomNumber
  ✅ should return a number with the specified length
  ✅ should return a different number on each call
  ✅ should return a number within the range of the specified length
HashUtil › generateUuid
  ✅ should return a string
  ✅ should return a different UUID on each call
  ✅ should return a valid UUID
HashUtil › hashPassword
  ✅ should return null when no password is provided
  ✅ should return a string when a password is provided
  ✅ should return a different hash when a different password is provided
HashUtil › isComparePassword
  ✅ should return false when no password or oldPassword is provided
  ✅ should return false when the oldPassword does not contain a salt or hashKey
  ✅ should return true when the password and oldPassword match

✅ tests/unit/utils/ip.util.test.ts

IpUtil › getIp
  ✅ should return cf-connecting-ip if it exists
  ✅ should return x-real-ip if cf-connecting-ip does not exist
  ✅ should return x-forwarded-for if cf-connecting-ip and x-real-ip do not exist
  ✅ should return req.ip if headers do not exist
  ✅ should return null if no ip is found
  ✅ should return the first ip if x-forwarded-for is an array
  ✅ should return the first ip if x-forwarded-for is a string of ips

✅ tests/unit/utils/joi.util.test.ts

JoiUtil › validate
  ✅ should return the value when it is valid
  ✅ should throw an error when the value is invalid
  ✅ should return the value when it is valid and the schema is complex
  ✅ should throw an error when the value is invalid and the schema is complex

✅ tests/unit/utils/mapping.util.test.ts

MappingUtil › objToDto
  ✅ should return an instance of the class when a class is provided
  ✅ should return the original data when no class is provided
  ✅ should return an array of instances of the class when an array of data and a class are provided
  ✅ should return the original array of data when an array of data and no class are provided

✅ tests/unit/utils/number.util.test.ts

NumberUtil › convertStringToNumber
  ✅ should return a number when a valid number string is provided
  ✅ should return a number when a valid number is provided
  ✅ should return 0 when an invalid number string is provided
  ✅ should return 0 when a non-number type is provided
  ✅ should return 0 when the input is null
  ✅ should return 0 when the input is undefined
NumberUtil › isNumber
  ✅ should return true when a number is provided
  ✅ should return true when a number string is provided
  ✅ should return false when a non-number string is provided
  ✅ should return false when an empty string is provided
  ✅ should return false when a non-number type is provided
  ✅ should return false when null is provided
  ✅ should return false when undefined is provided
  ✅ should return true when 0 is provided

✅ tests/unit/utils/queue.util.test.ts

QueueUtil
  ✅ should create a new Bull instance with the correct options
  ✅ should throw an error if name is not provided
  ✅ should throw an error if redisConfig.host is not provided
  ✅ should throw an error if redisConfig.port is not provided

✅ tests/unit/utils/request.util.test.ts

RequestUtil › get
  ✅ should return the expected data when the request is successful
  ✅ should throw an error when the request fails
  ✅ should throw an error when the response is not ok
RequestUtil › post
  ✅ should return the expected data when the request is successful
  ✅ should throw an error when the request fails
  ✅ should throw an error when the response is not ok

✅ tests/unit/utils/string.util.test.ts

StringUtil › capitalizeOnlyFirstChar
  ✅ should return the string with the first character capitalized
  ✅ should return the original string when the first character is already capitalized
  ✅ should return an empty string when the input is not a string
  ✅ should return an empty string when the input is undefined
  ✅ should return the original string when the string is empty
StringUtil › StringUtil › convertJsonToString
  ✅ should return a stringified JSON when a valid JSON is provided
  ✅ should return an empty string when the input is not a valid JSON
  ✅ should return a stringified JSON when an array is provided
  ✅ should return "null" when the input is null
  ✅ should return an empty string when the input is undefined
StringUtil › convertStringToJson
  ✅ should return a JSON object when a valid JSON string is provided
  ✅ should return an empty object when the input is not a valid JSON string
  ✅ should return a JSON array when a valid JSON array string is provided
  ✅ should return an empty object when the input is "null"
  ✅ should return an empty object  when the input is "undefined"
StringUtil › decodeBase64ToString
  ✅ should return a decoded string when a valid base64 string is provided
  ✅ should return an empty string when the input is not a valid base64 string
  ✅ should return an empty string when the input is not a string
  ✅ should return an empty string when the input is null
  ✅ should return an empty string when the input is undefined
StringUtil › escape
  ✅ should return a string with special characters escaped
  ✅ should return the original string when there are no special characters to escape
  ✅ should return an empty string when the input is an empty string
  ✅ should return an empty string when the input is null
  ✅ should return an empty string when the input is undefined
StringUtil › replace
  ✅ should return a string with placeholders replaced by the corresponding values
  ✅ should return the original string when there are no placeholders to replace
  ✅ should return the original string when the keys object is empty
  ✅ should return a string with placeholders replaced by the corresponding values when a custom delimiter is provided

✅ tests/unit/utils/template.util.test.ts

TemplateUtil
  ✅ should get message - markdown and html (with layout)
  ✅ should get message - markdown and html (without layout)
  ✅ should get message - markdown

✅ tests/unit/utils/url.util.test.ts

UrlUtil › getDomain
  ✅ should return the domain name when a valid URL is provided
  ✅ should return "localhost" when the URL is not provided
  ✅ should return "localhost" when the URL is invalid
  ✅ should return "localhost" when the URL is "localhost"
UrlUtil › createUrl
  ✅ should return the URL with search parameters when valid URL and search parameters are provided
  ✅ should return the original URL when search parameters are not provided
  ✅ should return the original URL when the URL is invalid
  ✅ should not append null or undefined search parameters

✅ tests/unit/utils/user-agent.util.test.ts

UserAgetUtil › getBrowser
  ✅ should return the browser Chrome if user agent string is valid
  ✅ should return the browser Safari if user agent string is valid
  ✅ should return an empty string if user agent string is invalid
  ✅ should return an empty string if user agent string is undefined
  ✅ should return an empty string if user agent string is null
UserAgetUtil › getOS
  ✅ should return the OS Windows if user agent string is valid
  ✅ should return the browser macOS if user agent string is valid
  ✅ should return an empty string if user agent string is invalid
  ✅ should return an empty string if user agent string is undefined
  ✅ should return an empty string if user agent string is null