fix tests from refactoring

This commit is contained in:
tiagosiebler
2022-09-10 13:00:38 +01:00
parent 66dcd09f18
commit 9d59d7074a
7 changed files with 50 additions and 57 deletions

View File

@@ -10,7 +10,7 @@ export function successResponseList(successMsg: string | null = 'OK') {
}; };
} }
export function successResponseListV3(successMsg: string | null = 'OK') { export function successResponseListV3() {
return { return {
result: { result: {
list: expect.any(Array), list: expect.any(Array),

View File

@@ -1,8 +1,5 @@
import { USDCOptionClient } from '../../../src'; import { USDCOptionClient } from '../../../src';
import { import { successResponseObjectV3 } from '../../response.util';
successResponseObject,
successUSDCResponseObject,
} from '../../response.util';
describe('Private Account Asset REST API Endpoints', () => { describe('Private Account Asset REST API Endpoints', () => {
const useLivenet = true; const useLivenet = true;
@@ -20,63 +17,61 @@ describe('Private Account Asset REST API Endpoints', () => {
it('getActiveRealtimeOrders()', async () => { it('getActiveRealtimeOrders()', async () => {
expect(await api.getActiveRealtimeOrders()).toMatchObject( expect(await api.getActiveRealtimeOrders()).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getActiveOrders()', async () => { it('getActiveOrders()', async () => {
expect(await api.getActiveOrders({ category })).toMatchObject( expect(await api.getActiveOrders({ category })).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getHistoricOrders()', async () => { it('getHistoricOrders()', async () => {
expect(await api.getHistoricOrders({ category })).toMatchObject( expect(await api.getHistoricOrders({ category })).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getOrderExecutionHistory()', async () => { it('getOrderExecutionHistory()', async () => {
expect(await api.getOrderExecutionHistory({ category })).toMatchObject( expect(await api.getOrderExecutionHistory({ category })).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getTransactionLog()', async () => { it('getTransactionLog()', async () => {
expect(await api.getTransactionLog({ type: 'TRADE' })).toMatchObject( expect(await api.getTransactionLog({ type: 'TRADE' })).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getBalances()', async () => { it('getBalances()', async () => {
expect(await api.getBalances()).toMatchObject(successUSDCResponseObject()); expect(await api.getBalances()).toMatchObject(successResponseObjectV3());
}); });
it('getAssetInfo()', async () => { it('getAssetInfo()', async () => {
expect(await api.getAssetInfo()).toMatchObject(successUSDCResponseObject()); expect(await api.getAssetInfo()).toMatchObject(successResponseObjectV3());
}); });
it('getMarginMode()', async () => { it('getMarginMode()', async () => {
expect(await api.getMarginMode()).toMatchObject( expect(await api.getMarginMode()).toMatchObject(successResponseObjectV3());
successUSDCResponseObject()
);
}); });
it('getPositions()', async () => { it('getPositions()', async () => {
expect(await api.getPositions({ category })).toMatchObject( expect(await api.getPositions({ category })).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getDeliveryHistory()', async () => { it('getDeliveryHistory()', async () => {
expect(await api.getDeliveryHistory({ symbol })).toMatchObject( expect(await api.getDeliveryHistory({ symbol })).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getPositionsInfoUponExpiry()', async () => { it('getPositionsInfoUponExpiry()', async () => {
expect(await api.getPositionsInfoUponExpiry()).toMatchObject( expect(await api.getPositionsInfoUponExpiry()).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
}); });

View File

@@ -1,5 +1,5 @@
import { API_ERROR_CODE, USDCOptionClient } from '../../../src'; import { API_ERROR_CODE, USDCOptionClient } from '../../../src';
import { successUSDCResponseObject } from '../../response.util'; import { successResponseObjectV3 } from '../../response.util';
describe('Private Account Asset REST API Endpoints', () => { describe('Private Account Asset REST API Endpoints', () => {
const useLivenet = true; const useLivenet = true;
@@ -132,7 +132,7 @@ describe('Private Account Asset REST API Endpoints', () => {
it('setMarginMode()', async () => { it('setMarginMode()', async () => {
expect(await api.setMarginMode('REGULAR_MARGIN')).toMatchObject( expect(await api.setMarginMode('REGULAR_MARGIN')).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });

View File

@@ -1,7 +1,7 @@
import { USDCOptionClient } from '../../../src'; import { USDCOptionClient } from '../../../src';
import { import {
successResponseObject, successResponseObject,
successUSDCResponseObject, successResponseObjectV3,
} from '../../response.util'; } from '../../response.util';
describe('Public USDC Options REST API Endpoints', () => { describe('Public USDC Options REST API Endpoints', () => {
@@ -14,37 +14,37 @@ describe('Public USDC Options REST API Endpoints', () => {
it('getOrderBook()', async () => { it('getOrderBook()', async () => {
expect(await api.getOrderBook(symbol)).toMatchObject( expect(await api.getOrderBook(symbol)).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getContractInfo()', async () => { it('getContractInfo()', async () => {
expect(await api.getContractInfo()).toMatchObject( expect(await api.getContractInfo()).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getSymbolTicker()', async () => { it('getSymbolTicker()', async () => {
expect(await api.getSymbolTicker(symbol)).toMatchObject( expect(await api.getSymbolTicker(symbol)).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getDeliveryPrice()', async () => { it('getDeliveryPrice()', async () => {
expect(await api.getDeliveryPrice()).toMatchObject( expect(await api.getDeliveryPrice()).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getLast500Trades()', async () => { it('getLast500Trades()', async () => {
expect(await api.getLast500Trades({ category: 'OPTION' })).toMatchObject( expect(await api.getLast500Trades({ category: 'OPTION' })).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getHistoricalVolatility()', async () => { it('getHistoricalVolatility()', async () => {
expect(await api.getHistoricalVolatility()).toMatchObject( expect(await api.getHistoricalVolatility()).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });

View File

@@ -1,5 +1,5 @@
import { USDCPerpetualClient } from '../../../src'; import { USDCPerpetualClient } from '../../../src';
import { successUSDCResponseObject } from '../../response.util'; import { successResponseObjectV3 } from '../../response.util';
describe('Private Account Asset REST API Endpoints', () => { describe('Private Account Asset REST API Endpoints', () => {
const useLivenet = true; const useLivenet = true;
@@ -18,57 +18,55 @@ describe('Private Account Asset REST API Endpoints', () => {
it('getActiveOrders()', async () => { it('getActiveOrders()', async () => {
expect(await api.getActiveOrders({ category })).toMatchObject( expect(await api.getActiveOrders({ category })).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getHistoricOrders()', async () => { it('getHistoricOrders()', async () => {
expect(await api.getHistoricOrders({ category })).toMatchObject( expect(await api.getHistoricOrders({ category })).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getOrderExecutionHistory()', async () => { it('getOrderExecutionHistory()', async () => {
expect(await api.getOrderExecutionHistory({ category })).toMatchObject( expect(await api.getOrderExecutionHistory({ category })).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getTransactionLog()', async () => { it('getTransactionLog()', async () => {
expect(await api.getTransactionLog({ type: 'TRADE' })).toMatchObject( expect(await api.getTransactionLog({ type: 'TRADE' })).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getBalances()', async () => { it('getBalances()', async () => {
expect(await api.getBalances()).toMatchObject(successUSDCResponseObject()); expect(await api.getBalances()).toMatchObject(successResponseObjectV3());
}); });
it('getAssetInfo()', async () => { it('getAssetInfo()', async () => {
expect(await api.getAssetInfo()).toMatchObject(successUSDCResponseObject()); expect(await api.getAssetInfo()).toMatchObject(successResponseObjectV3());
}); });
it('getMarginMode()', async () => { it('getMarginMode()', async () => {
expect(await api.getMarginMode()).toMatchObject( expect(await api.getMarginMode()).toMatchObject(successResponseObjectV3());
successUSDCResponseObject()
);
}); });
it('getPositions()', async () => { it('getPositions()', async () => {
expect(await api.getPositions({ category })).toMatchObject( expect(await api.getPositions({ category })).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getSettlementHistory()', async () => { it('getSettlementHistory()', async () => {
expect(await api.getSettlementHistory({ symbol })).toMatchObject( expect(await api.getSettlementHistory({ symbol })).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getPredictedFundingRate()', async () => { it('getPredictedFundingRate()', async () => {
expect(await api.getPredictedFundingRate(symbol)).toMatchObject( expect(await api.getPredictedFundingRate(symbol)).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
}); });

View File

@@ -1,7 +1,7 @@
import { API_ERROR_CODE, USDCPerpetualClient } from '../../../src'; import { API_ERROR_CODE, USDCPerpetualClient } from '../../../src';
import { import {
successUSDCEmptyResponseObject, successEmptyResponseObjectV3,
successUSDCResponseObject, successResponseObjectV3,
} from '../../response.util'; } from '../../response.util';
describe('Private Account Asset REST API Endpoints', () => { describe('Private Account Asset REST API Endpoints', () => {
@@ -62,13 +62,13 @@ describe('Private Account Asset REST API Endpoints', () => {
it('cancelActiveOrders()', async () => { it('cancelActiveOrders()', async () => {
expect(await api.cancelActiveOrders(symbol, 'Order')).toMatchObject( expect(await api.cancelActiveOrders(symbol, 'Order')).toMatchObject(
successUSDCEmptyResponseObject() successEmptyResponseObjectV3()
); );
}); });
it('setMarginMode()', async () => { it('setMarginMode()', async () => {
expect(await api.setMarginMode('REGULAR_MARGIN')).toMatchObject( expect(await api.setMarginMode('REGULAR_MARGIN')).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });

View File

@@ -1,7 +1,7 @@
import { USDCKlineRequest, USDCPerpetualClient } from '../../../src'; import { USDCKlineRequest, USDCPerpetualClient } from '../../../src';
import { import {
successResponseObject, successResponseObject,
successUSDCResponseObject, successResponseObjectV3,
} from '../../response.util'; } from '../../response.util';
describe('Public USDC Options REST API Endpoints', () => { describe('Public USDC Options REST API Endpoints', () => {
@@ -19,73 +19,73 @@ describe('Public USDC Options REST API Endpoints', () => {
it('getOrderBook()', async () => { it('getOrderBook()', async () => {
expect(await api.getOrderBook(symbol)).toMatchObject( expect(await api.getOrderBook(symbol)).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getContractInfo()', async () => { it('getContractInfo()', async () => {
expect(await api.getContractInfo()).toMatchObject( expect(await api.getContractInfo()).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getSymbolTicker()', async () => { it('getSymbolTicker()', async () => {
expect(await api.getSymbolTicker(symbol)).toMatchObject( expect(await api.getSymbolTicker(symbol)).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getCandles()', async () => { it('getCandles()', async () => {
expect(await api.getCandles(candleRequest)).toMatchObject( expect(await api.getCandles(candleRequest)).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getMarkPrice()', async () => { it('getMarkPrice()', async () => {
expect(await api.getMarkPrice(candleRequest)).toMatchObject( expect(await api.getMarkPrice(candleRequest)).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getIndexPrice()', async () => { it('getIndexPrice()', async () => {
expect(await api.getIndexPrice(candleRequest)).toMatchObject( expect(await api.getIndexPrice(candleRequest)).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getIndexPremium()', async () => { it('getIndexPremium()', async () => {
expect(await api.getIndexPremium(candleRequest)).toMatchObject( expect(await api.getIndexPremium(candleRequest)).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getOpenInterest()', async () => { it('getOpenInterest()', async () => {
expect(await api.getOpenInterest({ symbol, period: '1m' })).toMatchObject( expect(await api.getOpenInterest({ symbol, period: '1m' })).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getLargeOrders()', async () => { it('getLargeOrders()', async () => {
expect(await api.getLargeOrders({ symbol })).toMatchObject( expect(await api.getLargeOrders({ symbol })).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getLongShortRatio()', async () => { it('getLongShortRatio()', async () => {
expect(await api.getLongShortRatio({ symbol, period: '1m' })).toMatchObject( expect(await api.getLongShortRatio({ symbol, period: '1m' })).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getLast500Trades()', async () => { it('getLast500Trades()', async () => {
expect(await api.getLast500Trades({ category })).toMatchObject( expect(await api.getLast500Trades({ category })).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });
it('getLastFundingRate()', async () => { it('getLastFundingRate()', async () => {
expect(await api.getLastFundingRate(symbol)).toMatchObject( expect(await api.getLastFundingRate(symbol)).toMatchObject(
successUSDCResponseObject() successResponseObjectV3()
); );
}); });