aboutsummaryrefslogtreecommitdiffstats
path: root/packages/connect/test
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-02-14 03:34:54 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-02-14 06:15:54 +0800
commit713c922e351b284a4a17cde4899b133bfe939c4d (patch)
tree04bc54bc1401b931fd4fc4ebc8c13a602a634410 /packages/connect/test
parent07d00cc515e0f9825b81595386b358593b7a3d6f (diff)
downloaddexon-sol-tools-713c922e351b284a4a17cde4899b133bfe939c4d.tar
dexon-sol-tools-713c922e351b284a4a17cde4899b133bfe939c4d.tar.gz
dexon-sol-tools-713c922e351b284a4a17cde4899b133bfe939c4d.tar.bz2
dexon-sol-tools-713c922e351b284a4a17cde4899b133bfe939c4d.tar.lz
dexon-sol-tools-713c922e351b284a4a17cde4899b133bfe939c4d.tar.xz
dexon-sol-tools-713c922e351b284a4a17cde4899b133bfe939c4d.tar.zst
dexon-sol-tools-713c922e351b284a4a17cde4899b133bfe939c4d.zip
Add page options to relevant HttpClient methods
Diffstat (limited to 'packages/connect/test')
-rw-r--r--packages/connect/test/http_client_test.ts49
1 files changed, 34 insertions, 15 deletions
diff --git a/packages/connect/test/http_client_test.ts b/packages/connect/test/http_client_test.ts
index 15759d911..62a159628 100644
--- a/packages/connect/test/http_client_test.ts
+++ b/packages/connect/test/http_client_test.ts
@@ -40,19 +40,22 @@ describe('HttpClient', () => {
});
describe('#getTokenPairsAsync', () => {
const url = `${relayUrl}/token_pairs`;
- it('gets token pairs', async () => {
- fetchMock.get(url, tokenPairsResponseJSON);
+ it('gets token pairs with default options when none are provided', async () => {
+ const urlWithQuery = `${url}?page=0&per_page=100`;
+ fetchMock.get(urlWithQuery, tokenPairsResponseJSON);
const tokenPairs = await relayerClient.getTokenPairsAsync();
expect(tokenPairs).to.be.deep.equal(tokenPairsResponse);
});
- it('gets specific token pairs for request', async () => {
+ it('gets token pairs with specified request options', async () => {
const tokenAddress = '0x323b5d4c32345ced77393b3530b1eed0f346429d';
- const tokenPairsRequest = {
+ const tokenPairsRequestOpts = {
tokenA: tokenAddress,
+ page: 3,
+ per_page: 50,
};
- const urlWithQuery = `${url}?tokenA=${tokenAddress}`;
+ const urlWithQuery = `${url}?page=3&per_page=50&tokenA=${tokenAddress}`;
fetchMock.get(urlWithQuery, tokenPairsResponseJSON);
- const tokenPairs = await relayerClient.getTokenPairsAsync(tokenPairsRequest);
+ const tokenPairs = await relayerClient.getTokenPairsAsync(tokenPairsRequestOpts);
expect(tokenPairs).to.be.deep.equal(tokenPairsResponse);
});
it('throws an error for invalid JSON response', async () => {
@@ -62,17 +65,20 @@ describe('HttpClient', () => {
});
describe('#getOrdersAsync', () => {
const url = `${relayUrl}/orders`;
- it('gets orders', async () => {
- fetchMock.get(url, ordersResponseJSON);
+ it('gets orders with default options when none are provided', async () => {
+ const urlWithQuery = `${url}?page=0&per_page=100`;
+ fetchMock.get(urlWithQuery, ordersResponseJSON);
const orders = await relayerClient.getOrdersAsync();
expect(orders).to.be.deep.equal(ordersResponse);
});
- it('gets specific orders for request', async () => {
+ it('gets orders with specified request options', async () => {
const tokenAddress = '0x323b5d4c32345ced77393b3530b1eed0f346429d';
const ordersRequest = {
tokenAddress,
+ page: 3,
+ per_page: 50,
};
- const urlWithQuery = `${url}?tokenAddress=${tokenAddress}`;
+ const urlWithQuery = `${url}?page=3&per_page=50&tokenAddress=${tokenAddress}`;
fetchMock.get(urlWithQuery, ordersResponseJSON);
const orders = await relayerClient.getOrdersAsync(ordersRequest);
expect(orders).to.be.deep.equal(ordersResponse);
@@ -100,14 +106,27 @@ describe('HttpClient', () => {
baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d',
quoteTokenAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
};
- const url = `${relayUrl}/orderbook?baseTokenAddress=${request.baseTokenAddress}&quoteTokenAddress=${
- request.quoteTokenAddress
- }`;
- it('gets order book', async () => {
- fetchMock.get(url, orderbookJSON);
+ const url = `${relayUrl}/orderbook`;
+ it('gets orderbook with default page options when none are provided', async () => {
+ const urlWithQuery = `${url}?baseTokenAddress=${
+ request.baseTokenAddress
+ }&page=0&per_page=100&quoteTokenAddress=${request.quoteTokenAddress}`;
+ fetchMock.get(urlWithQuery, orderbookJSON);
const orderbook = await relayerClient.getOrderbookAsync(request);
expect(orderbook).to.be.deep.equal(orderbookResponse);
});
+ it('gets orderbook with specified page options', async () => {
+ const urlWithQuery = `${url}?baseTokenAddress=${
+ request.baseTokenAddress
+ }&page=3&per_page=50&quoteTokenAddress=${request.quoteTokenAddress}`;
+ fetchMock.get(urlWithQuery, orderbookJSON);
+ const pagedRequestOptions = {
+ page: 3,
+ per_page: 50,
+ };
+ const orderbook = await relayerClient.getOrderbookAsync(request, pagedRequestOptions);
+ expect(orderbook).to.be.deep.equal(orderbookResponse);
+ });
it('throws an error for invalid JSON response', async () => {
fetchMock.get(url, { test: 'dummy' });
expect(relayerClient.getOrderbookAsync(request)).to.be.rejected();