aboutsummaryrefslogtreecommitdiffstats
path: root/packages/connect/test/http_client_test.ts
diff options
context:
space:
mode:
authorBrandon Millman <brandon@0xproject.com>2018-01-13 04:18:03 +0800
committerGitHub <noreply@github.com>2018-01-13 04:18:03 +0800
commit80a46d14beec7544849247f9362db3de3bae04a8 (patch)
tree8ff60593fcd1b66c22bc9908bd96dead6653df41 /packages/connect/test/http_client_test.ts
parent97e01d7a427e18d740f692ccc8a65225b9d36268 (diff)
parentfbcbf066cdc13b99d1d280e131c01bd5456d90ae (diff)
downloaddexon-sol-tools-80a46d14beec7544849247f9362db3de3bae04a8.tar.gz
dexon-sol-tools-80a46d14beec7544849247f9362db3de3bae04a8.tar.zst
dexon-sol-tools-80a46d14beec7544849247f9362db3de3bae04a8.zip
Merge pull request #318 from 0xProject/feature/httpClientErrorImprovements
Improve HttpClient errors
Diffstat (limited to 'packages/connect/test/http_client_test.ts')
-rw-r--r--packages/connect/test/http_client_test.ts21
1 files changed, 15 insertions, 6 deletions
diff --git a/packages/connect/test/http_client_test.ts b/packages/connect/test/http_client_test.ts
index e7096edad..15759d911 100644
--- a/packages/connect/test/http_client_test.ts
+++ b/packages/connect/test/http_client_test.ts
@@ -29,14 +29,23 @@ describe('HttpClient', () => {
afterEach(() => {
fetchMock.restore();
});
+ describe('#constructor', () => {
+ it('should remove trailing slashes from api url', async () => {
+ const urlWithTrailingSlash = 'https://slash.com/';
+ const urlWithoutTrailingSlash = 'https://slash.com';
+ const client = new HttpClient(urlWithTrailingSlash);
+ const sanitizedUrl = (client as any)._apiEndpointUrl;
+ expect(sanitizedUrl).to.be.deep.equal(urlWithoutTrailingSlash);
+ });
+ });
describe('#getTokenPairsAsync', () => {
- const url = `${relayUrl}/v0/token_pairs`;
+ const url = `${relayUrl}/token_pairs`;
it('gets token pairs', async () => {
fetchMock.get(url, tokenPairsResponseJSON);
const tokenPairs = await relayerClient.getTokenPairsAsync();
expect(tokenPairs).to.be.deep.equal(tokenPairsResponse);
});
- it('gets specfic token pairs for request', async () => {
+ it('gets specific token pairs for request', async () => {
const tokenAddress = '0x323b5d4c32345ced77393b3530b1eed0f346429d';
const tokenPairsRequest = {
tokenA: tokenAddress,
@@ -52,7 +61,7 @@ describe('HttpClient', () => {
});
});
describe('#getOrdersAsync', () => {
- const url = `${relayUrl}/v0/orders`;
+ const url = `${relayUrl}/orders`;
it('gets orders', async () => {
fetchMock.get(url, ordersResponseJSON);
const orders = await relayerClient.getOrdersAsync();
@@ -75,7 +84,7 @@ describe('HttpClient', () => {
});
describe('#getOrderAsync', () => {
const orderHash = '0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f';
- const url = `${relayUrl}/v0/order/${orderHash}`;
+ const url = `${relayUrl}/order/${orderHash}`;
it('gets order', async () => {
fetchMock.get(url, orderResponseJSON);
const order = await relayerClient.getOrderAsync(orderHash);
@@ -91,7 +100,7 @@ describe('HttpClient', () => {
baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d',
quoteTokenAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
};
- const url = `${relayUrl}/v0/orderbook?baseTokenAddress=${request.baseTokenAddress}&quoteTokenAddress=${
+ const url = `${relayUrl}/orderbook?baseTokenAddress=${request.baseTokenAddress}&quoteTokenAddress=${
request.quoteTokenAddress
}`;
it('gets order book', async () => {
@@ -116,7 +125,7 @@ describe('HttpClient', () => {
salt: new BigNumber('256'),
expirationUnixTimestampSec: new BigNumber('42'),
};
- const url = `${relayUrl}/v0/fees`;
+ const url = `${relayUrl}/fees`;
it('gets fees', async () => {
fetchMock.post(url, feesResponseJSON);
const fees = await relayerClient.getFeesAsync(request);