bootstrap public spot test
This commit is contained in:
@@ -1,26 +1,19 @@
|
||||
|
||||
export function successResponseList() {
|
||||
export function successResponseList(successMsg: string | null = 'OK') {
|
||||
return {
|
||||
"ext_code": "",
|
||||
"ext_info": "",
|
||||
"result": expect.any(Array),
|
||||
"ret_code": 0,
|
||||
"ret_msg": "OK",
|
||||
"time_now": expect.any(String),
|
||||
result: expect.any(Array),
|
||||
ret_code: 0,
|
||||
ret_msg: successMsg,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export function successResponseObject() {
|
||||
export function successResponseObject(successMsg: string | null = 'OK') {
|
||||
return {
|
||||
"ext_code": "",
|
||||
"ext_info": "",
|
||||
"result": expect.any(Object),
|
||||
"ret_code": 0,
|
||||
"ret_msg": "OK",
|
||||
"time_now": expect.any(String),
|
||||
result: expect.any(Object),
|
||||
ret_code: 0,
|
||||
ret_msg: successMsg,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export function notAuthenticatedError() {
|
||||
return new Error('Private endpoints require api and private keys set');
|
||||
};
|
||||
}
|
||||
|
||||
37
test/spot/public.test.ts
Normal file
37
test/spot/public.test.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { SpotClient } from '../../src';
|
||||
import {
|
||||
notAuthenticatedError,
|
||||
successResponseList,
|
||||
successResponseObject,
|
||||
} from '../response.util';
|
||||
|
||||
describe('Public Spot REST API Endpoints', () => {
|
||||
const useLivenet = true;
|
||||
const api = new SpotClient(undefined, undefined, useLivenet, {
|
||||
disable_time_sync: true,
|
||||
});
|
||||
|
||||
const symbol = 'BTCUSDT';
|
||||
const interval = '15';
|
||||
const timestampOneHourAgo = new Date().getTime() / 1000 - 1000 * 60 * 60;
|
||||
const from = Number(timestampOneHourAgo.toFixed(0));
|
||||
|
||||
it('should throw for unauthenticated private calls', async () => {
|
||||
expect(() => api.getOpenOrders()).rejects.toMatchObject(
|
||||
notAuthenticatedError()
|
||||
);
|
||||
expect(() => api.getBalances()).rejects.toMatchObject(
|
||||
notAuthenticatedError()
|
||||
);
|
||||
});
|
||||
|
||||
it('getSymbols()', async () => {
|
||||
expect(await api.getSymbols()).toMatchObject(successResponseList(''));
|
||||
});
|
||||
|
||||
it('getOrderBook()', async () => {
|
||||
expect(await api.getOrderBook(symbol)).toMatchObject(
|
||||
successResponseObject(null)
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user