-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove double slash from api urls (#198)
- Loading branch information
1 parent
304bb80
commit 381f71a
Showing
32 changed files
with
615 additions
and
339 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import * as CONFIG from '@/data/keys/configKeys'; | ||
|
||
export const DEFAULT_LOCALE = 'nl-NL'; | ||
|
||
export const config = { | ||
[CONFIG.LOCALE]: 'nl-NL', | ||
[CONFIG.LOCALE]: DEFAULT_LOCALE, | ||
[CONFIG.ALLOW_MONDAY_DELIVERY]: true, | ||
[CONFIG.SATURDAY_CUTOFF_TIME]: '16:00', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
export const METHOD_GET = 'get'; | ||
|
||
export const ACCEPT_JSON = 'application/json'; | ||
|
||
export const ENDPOINT_PICKUP_LOCATIONS = 'pickup_locations'; | ||
export const ENDPOINT_DELIVERY_OPTIONS = 'delivery_options'; | ||
export const ENDPOINT_CARRIERS = 'carriers'; | ||
|
||
export const HEADER_ACCEPT = 'Accept'; | ||
export const HEADER_ACCEPT_LANGUAGE = 'Accept-Language'; | ||
export const HEADER_USER_AGENT = 'X-User-Agent'; | ||
|
||
export const endpointDeliveryOptions = Object.freeze({ | ||
endpoint: ENDPOINT_DELIVERY_OPTIONS, | ||
property: 'deliveries', | ||
}); | ||
|
||
export const endpointPickupLocations = Object.freeze({ | ||
endpoint: ENDPOINT_PICKUP_LOCATIONS, | ||
}); | ||
|
||
export const endpointCarriers = Object.freeze({ | ||
endpoint: ENDPOINT_CARRIERS, | ||
}); | ||
|
||
export const ENDPOINTS = Object.freeze([ | ||
endpointDeliveryOptions, | ||
endpointPickupLocations, | ||
endpointCarriers, | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
54 changes: 0 additions & 54 deletions
54
.../__mocks__/@myparcel/js-sdk/dist/data/delivery-options/entries/getDeliveryOptionsEntry.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { | ||
ENDPOINTS, | ||
ENDPOINT_CARRIERS, | ||
ENDPOINT_DELIVERY_OPTIONS, | ||
ENDPOINT_PICKUP_LOCATIONS, | ||
} from '@/delivery-options/data/endpoints'; | ||
import { fakeCarriersResponse } from '../mocks/fakeCarriersResponse'; | ||
import { fakeDeliveryOptionsResponse } from '../mocks/fakeDeliveryOptionsResponse'; | ||
import { fakePickupLocationsResponse } from '../mocks/fakePickupLocationsResponse'; | ||
|
||
global.fetch = jest.fn((url) => { | ||
const urlInstance = new URL(url); | ||
const endpoint = urlInstance.pathname.split('/').filter(Boolean)[0]; | ||
const params = Object.fromEntries(urlInstance.searchParams.entries()); | ||
|
||
let response = []; | ||
|
||
const matchingEndpoint = ENDPOINTS.find((endpointDefinition) => endpointDefinition.endpoint === endpoint); | ||
|
||
switch (endpoint) { | ||
case ENDPOINT_CARRIERS: | ||
response = fakeCarriersResponse(params); | ||
break; | ||
|
||
case ENDPOINT_DELIVERY_OPTIONS: | ||
response = fakeDeliveryOptionsResponse(params); | ||
break; | ||
|
||
case ENDPOINT_PICKUP_LOCATIONS: | ||
response = fakePickupLocationsResponse(params); | ||
break; | ||
|
||
default: | ||
throw new Error(`Unknown endpoint: ${endpoint}`); | ||
} | ||
|
||
return Promise.resolve({ | ||
ok: true, | ||
status: 200, | ||
statusText: 'OK', | ||
json: () => { | ||
return Promise.resolve({ | ||
data: { | ||
[matchingEndpoint?.property ?? matchingEndpoint?.endpoint ?? 'unknown']: response, | ||
}, | ||
}); | ||
}, | ||
}); | ||
}); |
2 changes: 1 addition & 1 deletion
2
...a/delivery-options/cutoffTimeHasPassed.js → ...s/delivery-options/cutoffTimeHasPassed.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.