test coverage for public unified margin endpoints

This commit is contained in:
tiagosiebler
2022-09-10 19:07:58 +01:00
parent 0cbdc5351c
commit 8e60d5dfdf
6 changed files with 268 additions and 2 deletions

View File

@@ -0,0 +1,108 @@
import {
USDCKlineRequest,
UnifiedMarginClient,
UMCandlesRequest,
} from '../../src';
import {
successResponseObject,
successResponseObjectV3,
} from '../response.util';
describe('Public USDC Options REST API Endpoints', () => {
const useLivenet = true;
const API_KEY = undefined;
const API_SECRET = undefined;
const api = new UnifiedMarginClient(API_KEY, API_SECRET, useLivenet);
const symbol = 'BTCUSDT';
const category = 'linear';
const start = Number((Date.now() / 1000).toFixed(0));
const end = start + 1000 * 60 * 60 * 24;
const interval = '1';
const candleRequest: UMCandlesRequest = {
category,
symbol,
interval,
start,
end,
};
it('getOrderBook()', async () => {
expect(await api.getOrderBook(symbol, category)).toMatchObject(
successResponseObjectV3()
);
});
it('getCandles()', async () => {
expect(await api.getCandles(candleRequest)).toMatchObject(
successResponseObjectV3()
);
});
it('getSymbolTicker()', async () => {
expect(await api.getSymbolTicker(category)).toMatchObject(
successResponseObjectV3()
);
});
it('getInstrumentInfo()', async () => {
expect(await api.getInstrumentInfo({ category })).toMatchObject(
successResponseObjectV3()
);
});
it('getMarkPrice()', async () => {
expect(await api.getMarkPriceCandles(candleRequest)).toMatchObject(
successResponseObjectV3()
);
});
it('getIndexPrice()', async () => {
expect(await api.getIndexPriceCandles(candleRequest)).toMatchObject(
successResponseObjectV3()
);
});
it('getLastFundingRate()', async () => {
expect(
await api.getFundingRateHistory({
category,
symbol,
})
).toMatchObject(successResponseObjectV3());
});
it('getRiskLimit()', async () => {
expect(await api.getRiskLimit(category, symbol)).toMatchObject(
successResponseObjectV3()
);
});
it('getOptionDeliveryPrice()', async () => {
expect(await api.getOptionDeliveryPrice({ category })).toMatchObject(
successResponseObjectV3()
);
});
it('getTrades()', async () => {
expect(await api.getTrades({ category, symbol })).toMatchObject(
successResponseObjectV3()
);
});
it('getOpenInterest()', async () => {
expect(
await api.getOpenInterest({ symbol, category, interval: '5min' })
).toMatchObject(successResponseObjectV3());
});
it('getServerTime()', async () => {
expect(await api.getServerTime()).toMatchObject(successResponseObject());
});
it('getAnnouncements()', async () => {
expect(await api.getAnnouncements()).toMatchObject(successResponseObject());
});
});