- 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.
49 lines
991 B
TypeScript
49 lines
991 B
TypeScript
import { API_ERROR_CODE } from '../src';
|
|
|
|
const SUCCESS_MSG_REGEX = /success/gim;
|
|
|
|
export function successResponseString() {
|
|
return {
|
|
data: expect.any(String),
|
|
...sucessEmptyResponseObject(),
|
|
};
|
|
}
|
|
|
|
export function sucessEmptyResponseObject() {
|
|
return {
|
|
code: API_ERROR_CODE.SUCCESS,
|
|
msg: expect.stringMatching(SUCCESS_MSG_REGEX),
|
|
};
|
|
}
|
|
|
|
export function errorResponseObject(
|
|
result: null | any = null,
|
|
ret_code: number,
|
|
ret_msg: string,
|
|
) {
|
|
return {
|
|
result,
|
|
ret_code,
|
|
ret_msg,
|
|
};
|
|
}
|
|
|
|
export function errorResponseObjectV3(code: string, statusCode: number = 400) {
|
|
return {
|
|
body: {
|
|
code,
|
|
data: null,
|
|
msg: expect.any(String),
|
|
requestTime: expect.any(Number),
|
|
},
|
|
code: statusCode,
|
|
headers: expect.any(Object),
|
|
message: expect.any(String),
|
|
requestOptions: expect.any(Object),
|
|
};
|
|
}
|
|
|
|
export function notAuthenticatedError() {
|
|
return new Error('Private endpoints require api and private keys set');
|
|
}
|