Skip to content

Commit

Permalink
fix(): failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagosiebler committed Nov 8, 2024
1 parent 725f252 commit f685dc1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
23 changes: 14 additions & 9 deletions test/v5/private.read.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe('Private READ V5 REST API Endpoints', () => {

const settleCoin = 'USDT';
const linearSymbol = 'BTCUSDT';
const accountType = 'UNIFIED';

describe('misc endpoints', () => {
it('fetchServerTime()', async () => {
Expand Down Expand Up @@ -84,21 +85,19 @@ describe('Private READ V5 REST API Endpoints', () => {
describe('Account APIs', () => {
it('getWalletBalance()', async () => {
expect(
await api.getWalletBalance({ accountType: 'CONTRACT' }),
await api.getWalletBalance({ accountType: accountType }),
).toMatchObject({ ...successResponseObjectV3() });
});

it('getBorrowHistory()', async () => {
expect(await api.getBorrowHistory()).toMatchObject({
...successResponseObjectV3(),
retCode: API_ERROR_CODE.INCORRECT_API_KEY_PERMISSIONS,
});
});

it('getCollateralInfo()', async () => {
expect(await api.getCollateralInfo()).toMatchObject({
...successResponseObjectV3(),
retCode: API_ERROR_CODE.INCORRECT_API_KEY_PERMISSIONS,
});
});

Expand Down Expand Up @@ -127,7 +126,7 @@ describe('Private READ V5 REST API Endpoints', () => {
it('getTransactionLog()', async () => {
expect(await api.getTransactionLog()).toMatchObject({
...successResponseObjectV3(),
retCode: API_ERROR_CODE.INCORRECT_API_KEY_PERMISSIONS,
// retMsg: '',
});
});

Expand All @@ -151,7 +150,7 @@ describe('Private READ V5 REST API Endpoints', () => {
expect(await api.getDeliveryRecord({ category: 'option' })).toMatchObject(
{
...successResponseObjectV3(),
retCode: API_ERROR_CODE.INCORRECT_API_KEY_PERMISSIONS,
// retCode: API_ERROR_CODE.INCORRECT_API_KEY_PERMISSIONS,
},
);
});
Expand All @@ -161,7 +160,7 @@ describe('Private READ V5 REST API Endpoints', () => {
await api.getSettlementRecords({ category: 'linear' }),
).toMatchObject({
...successResponseObjectV3(),
retCode: API_ERROR_CODE.INCORRECT_API_KEY_PERMISSIONS,
// retCode: API_ERROR_CODE.INCORRECT_API_KEY_PERMISSIONS,
});
});

Expand All @@ -173,13 +172,19 @@ describe('Private READ V5 REST API Endpoints', () => {

it('getAllCoinsBalance()', async () => {
expect(
await api.getAllCoinsBalance({ accountType: 'SPOT' }),
).toMatchObject({ ...successResponseObjectV3() });
await api.getAllCoinsBalance({ accountType: accountType }),
).toMatchObject({
...successResponseObjectV3(),
// retMsg: '',
});
});

it('getCoinBalance()', async () => {
expect(
await api.getCoinBalance({ accountType: 'SPOT', coin: settleCoin }),
await api.getCoinBalance({
accountType: accountType,
coin: settleCoin,
}),
).toMatchObject({ ...successResponseObjectV3() });
});

Expand Down
24 changes: 13 additions & 11 deletions test/v5/private.write.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ describe('Private WRITE V5 REST API Endpoints', () => {
});
});

it('switchIsolatedMargin()', async () => {
// Not compatible with account mode
it.skip('switchIsolatedMargin()', async () => {
expect(
await api.switchIsolatedMargin({
category: 'linear',
Expand All @@ -211,7 +212,7 @@ describe('Private WRITE V5 REST API Endpoints', () => {
}),
).toMatchObject({
// ...successResponseObjectV3(),
// retMsg: '',
retMsg: '',
retCode: API_ERROR_CODE.V5_CROSS_ISOLATED_MARGIN_NOT_CHANGED,
});
});
Expand Down Expand Up @@ -275,7 +276,8 @@ describe('Private WRITE V5 REST API Endpoints', () => {
});
});

it('setAutoAddMargin()', async () => {
// Not compatible with account mode
it.skip('setAutoAddMargin()', async () => {
expect(
await api.setAutoAddMargin({
category: 'linear',
Expand All @@ -284,8 +286,8 @@ describe('Private WRITE V5 REST API Endpoints', () => {
positionIdx: 0,
}),
).toMatchObject({
// ...successResponseObjectV3(),
// retMsg: '',
...successResponseObjectV3(),
retMsg: '',
retCode: API_ERROR_CODE.V5_AUTO_ADD_MARGIN_NOT_CHANGED,
});
});
Expand All @@ -294,9 +296,9 @@ describe('Private WRITE V5 REST API Endpoints', () => {
describe('Account APIs', () => {
it('setMarginMode()', async () => {
expect(await api.setMarginMode('REGULAR_MARGIN')).toMatchObject({
// ...successResponseObjectV3(),
...successResponseObjectV3(),
// retMsg: '',
retCode: API_ERROR_CODE.V5_MARGIN_MODE_NOT_CHANGED,
// retCode: API_ERROR_CODE.V5_MARGIN_MODE_NOT_CHANGED,
});
});

Expand Down Expand Up @@ -468,17 +470,17 @@ describe('Private WRITE V5 REST API Endpoints', () => {
describe('Spot Margin APIs', () => {
it('toggleSpotMarginTrade()', async () => {
expect(await api.toggleSpotMarginTrade('1')).toMatchObject({
// ...successResponseObjectV3(),
...successResponseObjectV3(),
// retMsg: '',
retCode: API_ERROR_CODE.INCORRECT_API_KEY_PERMISSIONS,
// retCode: API_ERROR_CODE.INCORRECT_API_KEY_PERMISSIONS,
});
});

it('setSpotMarginLeverage()', async () => {
expect(await api.setSpotMarginLeverage('2')).toMatchObject({
// ...successResponseObjectV3(),
...successResponseObjectV3(),
// retMsg: '',
retCode: API_ERROR_CODE.INCORRECT_API_KEY_PERMISSIONS,
// retCode: API_ERROR_CODE.INCORRECT_API_KEY_PERMISSIONS,
});
});
});
Expand Down

0 comments on commit f685dc1

Please sign in to comment.