feat(): add comprehensive tests for Bitget Private and Public REST API endpoints

- Introduced new test files for private read and write endpoints, covering account, trade, funding, and futures functionalities.
- Added public API tests for server time, ticker, order book, and market trades - Enhanced error handling in tests with specific error codes and messages.
- Updated response utility functions to improve error response structure.
- Removed outdated broker tests to streamline the test suite.
This commit is contained in:
JJ-Cro
2025-03-17 13:38:04 +01:00
parent e31c5fa4af
commit 1e7987a400
12 changed files with 453 additions and 1744 deletions

76
test/public.test.ts Normal file
View File

@@ -0,0 +1,76 @@
import { RestClientV2 } from '../src/rest-client-v2';
import { sucessEmptyResponseObject } from './response.util';
describe('Bitget Public REST API Endpoints', () => {
const api = new RestClientV2();
describe('public endpoints', () => {
it('should succeed making a GET request without params', async () => {
const res = await api.getServerTime();
expect(res).toMatchObject(sucessEmptyResponseObject());
});
it('should succeed making a GET request with params', async () => {
const res = await api.getSpotTicker({ symbol: 'BTCUSDT' });
expect(res).toMatchObject(sucessEmptyResponseObject());
});
it('should return orderbook data', async () => {
const res = await api.getSpotOrderBookDepth({
symbol: 'BTCUSDT',
type: 'step0',
limit: '20',
});
expect(res).toMatchObject(sucessEmptyResponseObject());
});
it('should return candles data', async () => {
const res = await api.getSpotCandles({
symbol: 'BTCUSDT',
granularity: '1min',
limit: '100',
});
expect(res).toMatchObject(sucessEmptyResponseObject());
});
it('should return recent trades', async () => {
const res = await api.getSpotRecentTrades({
symbol: 'BTCUSDT',
limit: '20',
});
expect(res).toMatchObject(sucessEmptyResponseObject());
});
it('should return historic trades', async () => {
const res = await api.getSpotHistoricTrades({
symbol: 'BTCUSDT',
limit: '20',
});
expect(res).toMatchObject(sucessEmptyResponseObject());
});
it('should return funding rate data', async () => {
const res = await api.getFuturesCurrentFundingRate({
symbol: 'BTCUSDT',
productType: 'USDT-FUTURES',
});
expect(res).toMatchObject(sucessEmptyResponseObject());
});
it('should return open interest data', async () => {
const res = await api.getFuturesOpenInterest({
symbol: 'BTCUSDT',
productType: 'USDT-FUTURES',
});
expect(res).toMatchObject(sucessEmptyResponseObject());
});
it('should return contract config', async () => {
const res = await api.getFuturesContractConfig({
symbol: 'BTCUSDT',
productType: 'USDT-FUTURES',
});
expect(res).toMatchObject(sucessEmptyResponseObject());
});
});
});