radarlabs / radar-sdk-js

Web JavaScript SDK for Radar, the leading geofencing and location tracking platform
https://radar.com
Apache License 2.0
42 stars 11 forks source link

Use BASE_API_PATH for all endpoints in JS SDK #75

Closed jaspk06 closed 1 year ago

jaspk06 commented 1 year ago

Story details: https://app.shortcut.com/radarlabs/story/12086

All tests pass

  Context
    getContext
      location permissions denied
        ✓ should throw a navigation error
      location permissions approved
        ✓ should return a context response

  Geocoding
    geocode
      ✓ should return an address
    reverseGeocode
      location permissions denied
        ✓ should propagate the navigator error
      location permissions approved
        ✓ should return a geocode response
    ipGeocode
      ✓ should return a geocode response

  Routing
    getDistanceToDestination
      location permissions denied
        ✓ should throw a navigation error
      location permissions approved
        no args given
          ✓ should return a routing response
        all args given
          ✓ should return a routing response
    getMatrixDistances
      location permissions denied
        ✓ should throw a navigation error
      location permissions approved
        no args given
          ✓ should return a routing response
        all args given
          ✓ should return a routing response

  Search
    searchPlaces
      location permissions denied
        ✓ should propagate the navigator error
      location permissions approved
        ✓ should return a placeSearch response
      location is given
        ✓ should return a placeSearch response
    searchGeofences
      location permissions denied
        ✓ should propagate the navigator error
      location permissions approved
        ✓ should return a geofenceSearch response
      location is given
        ✓ should return a geofenceSearch response
    autocomplete
      params are not provided
        ✓ should have undefined params and return an autocomplete response
      params are provided
        ✓ should return an autocomplete response

  Track
    trackOnce
      location permissions denied
        ✓ should propagate the navigator error
      location permissions approved
        ✓ should return a track response with metadata
        ✓ should return a track response without metadata

  Trips
    startTrip
      called without tripOptions
        ✓ should include tripOptions each set to unknown
        ✓ should include tripOptions
    updateTrip
      called without status
        ✓ should include status unknown
      called with status
        ✓ should include status

  Device
    getId
      deviceId has not been set
        ✓ should generate a new deviceId in storage, and return the value
      deviceId has already been set
        ✓ should return the deviceId stored saved in the storage

  Http
    http requests
      success
        ✓ should return api response on success
        ✓ should always include Device-Type and SDK-Version headers
        ✓ should filter out undefined values in data
      error
        ✓ should return bad request error
        ✓ should return bad request error
        ✓ should return unauthorized error
        ✓ should return payment required error
        ✓ should return forbidden error
        ✓ should return not found error
        ✓ should return rate limit error
        ✓ should return server error
        ✓ should return unknown error
        ✓ should respond with server error status on request error
        ✓ should respond with network error status on timeout
        ✓ should return a publishable key error if not set
        ✓ should return a server error on invalid JSON
    GET request
      ✓ should inject GET parameters into the url querystring
      ✓ should not append querystring of no params
    custom headers
      ✓ should include headers in request

  Radar
    VERSION
      ✓ should return sdk version
    STATUS
      ✓ should return the list of possible status codes
    initialize
      no publishable key given
        ✓ should print a warning to the console
      called with publishable key
        ✓ should save publishable key to storage
    setHost
      ✓ should save the host to storage
    setUserId
      no userId given
        ✓ should delete userId from storage
      userId given
        ✓ should save userId in storage
    setDeviceId
      no deviceId given
        ✓ should delete deviceId from storage
      deviceId given
        ✓ should save deviceId in storage
        ✓ should save deviceId with installId in storage
    setDescription
      no description given
        ✓ should delete description from storage
      description given
        ✓ should save description in storage
    setMetadata
      no metadata given
        ✓ should delete metadata from storage
      metadata given
        ✓ should save metadata in storage
    setRequestHeaders
      no headers given
        ✓ should delete metadata from storage
      headers given
        ✓ should save metadata in storage
    api errors
      Radar error
        ✓ should return the error enum and empty object
      Http Error
        ✓ should return the error enum and response object
      Unknown
        ✓ should return the unknown error and empty object
    getLocation
      ✓ should propagate the err if not successful
      ✓ should succeed
    trackOnce
      ✓ should call trackOnce if the first arg is a callback
      ✓ should call trackOnce if the first arg is a location object
      ✓ should not throw an error if no callback given
    getContext
      ✓ should call getContext if the first arg is a callback
      ✓ should call getContext if the first arg is a location
    searchPlaces
      ✓ should call searchPlaces
    searchGeofences
      ✓ should call searchGeofences
    autocomplete
      ✓ should call autocomplete
    geocode
      ✓ should call geocode
    reverseGeocode
      ✓ should call reverseGeocode if the first arg is a callback
      ✓ should call reverseGeocodeLocation if the first arg is a location object
    ipGeocode
      ✓ should call ipGeocode if the first arg is a callback
      ✓ should call ipGeocode is the first arg is an object
    getDistance
      ✓ should call getDistanceToDestination

  Navigator
    ✓ should report a location error if geolocation is not available
    ✓ should report a location error if position coordinates are not available
    ✓ should report a permissions error if the user denies location permissions
    ✓ should report a location error if the device errors out fetching location
    ✓ should succeed

  Storage
    getItem
      ✓ should return value of sessionStorage from a given key
      ✓ should return null if key not found
      ✓ should return null if sessionStorage key is undefined
    setItem
      ✓ should write the key and value to the browsers sessionStorage
    clear & removeItem
      ✓ should delete session Storage
      ✓ should clear session storage

  VERSION
    ✓ should match version in package.json
    ✓ should match version in package-lock.json

  96 passing (87ms)
shortcut-integration[bot] commented 1 year ago

This pull request has been linked to Shortcut Story #12086: Use BASE_API_PATH for all endpoints in JS SDK.