Skip to content

Merge pull request #149 from contentstack/fix/version-bump

4822074
Select commit
Loading
Failed to load commit list.
Sign in for the full log view
Merged

version bump #150

Merge pull request #149 from contentstack/fix/version-bump
4822074
Select commit
Loading
Failed to load commit list.
GitHub Actions / JEST Tests succeeded Nov 3, 2025 in 0s

103 passed, 0 failed and 0 skipped

Tests passed successfully

✅ reports/contentstack-js-core/junit/jest-junit.xml

103 tests were completed in 5s with 103 passed, 0 failed and 0 skipped.

Test suite Passed Failed Skipped Time
test/api-error.spec.ts 15✅ 3s
test/contentstack-core.spec.ts 13✅ 490ms
test/contentstack-error.spec.ts 4✅ 59ms
test/param-serializer.spec.ts 5✅ 52ms
test/request.spec.ts 20✅ 3s
test/retryPolicy/delivery-sdk-handlers.spec.ts 46✅ 4s

✅ test/api-error.spec.ts

APIError › constructor
  ✅ should create an APIError with all properties
  ✅ should create an APIError with numeric error_code
APIError › fromAxiosError
  ✅ should create APIError from axios error with response data
  ✅ should create APIError from axios error with message but no response
  ✅ should create APIError from axios error with message but no code
  ✅ should create APIError with default message for unknown errors
  ✅ should handle axios error with response.data but no response.status
APIError › fromResponseData
  ✅ should create APIError from response data with error_message
  ✅ should create APIError from response data with message fallback
  ✅ should create APIError from response data with error fallback
  ✅ should create APIError from string response data
  ✅ should create APIError with default message when no error fields present
  ✅ should extract error_code from response data
  ✅ should extract code from response data when error_code not present
  ✅ should use status as error_code fallback

✅ test/contentstack-core.spec.ts

contentstackCore
  ✅ should return default config when no config is passed
contentstackCore › logHandler
  ✅ should log an error message when level is "error" and data is provided
  ✅ should not log anything when level is "error" and no data is provided
  ✅ should log a message with the provided level and data
contentstackCore › retryCondition
  ✅ should return true when error response status is 429
  ✅ should return false when error response status is not 429
  ✅ should return false when error response is not present
contentstackCore › config.headers
  ✅ should include apiKey in headers when provided
  ✅ should include accessToken in headers when provided
  ✅ should not include apiKey in headers when not provided
  ✅ should not include accessToken in headers when not provided
contentstackCore › config.onError
  ✅ should call the onError function when an error occurs
  ✅ should not call the onError function when no error occurs

✅ test/contentstack-error.spec.ts

Contentstack Error
  ✅ should throw an error with proper details
  ✅ should throw an error with a default message if response or config is not present
  ✅ should throw an error with a default details if response data is not present
  ✅ should throw an error with proper details when response.data is not available

✅ test/param-serializer.spec.ts

serialize
  ✅ should return blank string when passed empty params
  ✅ should return brackets structure when param contains array value
  ✅ should return non brackets string when param value is not array value
  ✅ should return query with encode string when passed query param
  ✅ should return brackets and query with encoded string when passed query param and array value

✅ test/request.spec.ts

Request tests
  ✅ should fetch successfully data from an API
  ✅ should handle errors
  ✅ should throw error when host is required for live preview
  ✅ should handle live_preview with enable=true and live_preview=init
  ✅ should set baseURL correctly when host is provided without https://
  ✅ should not modify baseURL when host is already prefixed with https://
  ✅ should throw error when response has no data property
  ✅ should throw error when response is null
  ✅ should handle live_preview when enable is false
  ✅ should handle request when stackConfig is undefined
  ✅ should handle request when stackConfig exists but live_preview is undefined
  ✅ should set live_preview to "init" when enable is true and no live_preview provided
  ✅ should set headers when preview_token is provided
  ✅ should handle live_preview when enable is true but no preview_token
  ✅ should handle custom error messages when request fails
  ✅ should handle non-Error objects as errors when they have message property
  ✅ should handle non-Error objects as errors when they have no message property
  ✅ should pass data parameter to axios get request
  ✅ should handle React Native compatibility by avoiding URLSearchParams.set()
  ✅ should use instance.request when URL length exceeds 2000 characters

✅ test/retryPolicy/delivery-sdk-handlers.spec.ts

retryRequestHandler
  ✅ should add retryCount to the request config
retryResponseHandler
  ✅ should return the response as-is
retryResponseErrorHandler
  ✅ should reject the promise if retryOnError is false
  ✅ should reject the promise if retryOnError is true
  ✅ should resolve the promise to 408 error if retryOnError is true and error code is ECONNABORTED
  ✅ should reject the promise if response status is 429 and retryCount exceeds retryLimit
  ✅ should reject the promise if response status is 401 and retryCount exceeds retryLimit
  ✅ should reject the promise if response status is 429 or 401 and retryCount is within limit
  ✅ should call the retry function if retryCondition is passed
  ✅ should reject to error when retryCondition is passed but retryLimit is exceeded
  ✅ should retry when response status is 429 and retryCount is less than retryLimit
  ✅ should use configured retryDelay for 429 status retries
  ✅ should use configured retryDelay for 401 status retries
  ✅ should use default retryDelay (300ms) when not configured for 429 retries
  ✅ should use default retryDelay (300ms) when retryDelay is explicitly undefined
  ✅ should use default retryDelay (300ms) when retryDelay is null
  ✅ should use default delay in retry function when retryDelay is 0
  ✅ should use config.retryDelay when retryDelay parameter is 0 in retry function
  ✅ should retry when retryCondition is true
  ✅ should use configured retryDelay when retryCondition triggers retry
  ✅ should retry with delay when x-ratelimit-remaining is 0 and retry-after header is present
  ✅ should retry with delay when x-ratelimit-remaining is 0 and x-ratelimit-reset header is present
  ✅ should retry with default delay when x-ratelimit-remaining is 0 and no reset headers are present
  ✅ should reject with rate limit error when x-ratelimit-remaining is 0 and retry limit is exceeded
  ✅ should retry when x-ratelimit-remaining is greater than 0
  ✅ should retry when x-ratelimit-remaining header is not present
  ✅ should successfully retry after rate limit token replenishment using x-ratelimit-reset-time header
  ✅ should handle token replenishment scenario with increasing delay
  ✅ should simulate real-world token bucket replenishment after rate limit exhaustion
  ✅ should handle retry error rejection when rate limited request fails on retry
  ✅ should reject promise when retry fails for 429 status with retry-after header
  ✅ should reject promise when retry fails for 401/429 status with retryDelay
  ✅ should reject promise when retry fails in retryCondition path
  ✅ should reject with original error when 429/401 response has no data
  ✅ should create and throw custom error for non-retryable responses
  ✅ should create custom error for 500 internal server error
  ✅ should handle custom error for 422 unprocessable entity
calculateRateLimitDelay
  ✅ should return delay from retry-after header in milliseconds
  ✅ should return delay from x-ratelimit-reset header with Unix timestamp
  ✅ should return minimum delay when x-ratelimit-reset is in the past
  ✅ should return delay from x-ratelimit-reset-time header with ISO string
  ✅ should return minimum delay when x-ratelimit-reset-time is in the past
  ✅ should return default fallback delay when no rate limit headers are present
  ✅ should return default fallback delay when headers have other unrelated values
  ✅ should prioritize retry-after over other headers
  ✅ should prioritize x-ratelimit-reset over x-ratelimit-reset-time when retry-after is not present