From 49b739fa5c941a01b202568990159fc053c31b5d Mon Sep 17 00:00:00 2001 From: Tiago Siebler Date: Tue, 29 Aug 2023 11:17:31 +0100 Subject: [PATCH] chore(): fix tests with new api error codes --- src/constants/enum.ts | 3 +++ test/broker/private.write.test.ts | 2 +- test/futures/private.write.test.ts | 9 +++++---- test/spot/private.write.test.ts | 6 ++++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/constants/enum.ts b/src/constants/enum.ts index 63c18e6..20d84f4 100644 --- a/src/constants/enum.ts +++ b/src/constants/enum.ts @@ -1,5 +1,6 @@ export const API_ERROR_CODE = { SUCCESS: '00000', + NO_ORDER_TO_CANCEL: '22001', INCORRECT_PERMISSIONS: '40014', ACCOUNT_NOT_COPY_TRADER: '40017', FUTURES_POSITION_DIRECTION_EMPTY: '40017', @@ -17,4 +18,6 @@ export const API_ERROR_CODE = { ORDER_NOT_FOUND: '43001', FUTURES_ORDER_TPSL_NOT_FOUND: '43020', PLAN_ORDER_NOT_FOUND: '43025', + QTY_LESS_THAN_MINIMUM_SPOT: '45110', + PASSPHRASE_CANNOT_BE_EMPTY: '400172', } as const; diff --git a/test/broker/private.write.test.ts b/test/broker/private.write.test.ts index c9dd3ef..32d8c3a 100644 --- a/test/broker/private.write.test.ts +++ b/test/broker/private.write.test.ts @@ -118,7 +118,7 @@ describe('Private Broker REST API POST Endpoints', () => { ).toMatchObject(sucessEmptyResponseObject()); } catch (e) { expect(e.body).toMatchObject({ - code: '40017', + code: API_ERROR_CODE.PASSPHRASE_CANNOT_BE_EMPTY, }); } }); diff --git a/test/futures/private.write.test.ts b/test/futures/private.write.test.ts index bcf4ea5..d4acc85 100644 --- a/test/futures/private.write.test.ts +++ b/test/futures/private.write.test.ts @@ -84,7 +84,6 @@ describe('Private Futures REST API POST Endpoints', () => { data: {}, }); } catch (e) { - // console.log(`submitOrder() exception: `, e.body); expect(e.body).toMatchObject({ // seems to be the new "insufficient balance" error, informed bitget on 7th feb code: API_ERROR_CODE.QTY_GREATER_THAN_MAX_OPEN, @@ -150,8 +149,9 @@ describe('Private Futures REST API POST Endpoints', () => { data: {}, }); } catch (e) { - console.error('cancelAllOrders: ', e); - expect(e).toBeNull(); + expect(e.body).toMatchObject({ + code: API_ERROR_CODE.NO_ORDER_TO_CANCEL, + }); } }); @@ -253,6 +253,7 @@ describe('Private Futures REST API POST Endpoints', () => { holdSide: 'long', planType: 'profit_plan', triggerPrice: '50', + triggerType: 'market_price', }), ).toMatchObject({ ...sucessEmptyResponseObject(), @@ -260,7 +261,7 @@ describe('Private Futures REST API POST Endpoints', () => { }); } catch (e) { expect(e.body).toMatchObject({ - code: API_ERROR_CODE.FUTURES_POSITION_DIRECTION_EMPTY, + code: API_ERROR_CODE.FUTURES_INSUFFICIENT_POSITION_NO_TPSL, }); } }); diff --git a/test/spot/private.write.test.ts b/test/spot/private.write.test.ts index 1aa42be..d708f7b 100644 --- a/test/spot/private.write.test.ts +++ b/test/spot/private.write.test.ts @@ -165,7 +165,7 @@ describe('Private Spot REST API POST Endpoints', () => { }); } catch (e) { expect(e.body).toMatchObject({ - code: API_ERROR_CODE.QTY_LESS_THAN_MINIMUM, + code: API_ERROR_CODE.QTY_LESS_THAN_MINIMUM_SPOT, }); } }); @@ -185,10 +185,12 @@ describe('Private Spot REST API POST Endpoints', () => { ...sucessEmptyResponseObject(), data: { resultList: expect.any(Array), - failure: [{ errorCode: API_ERROR_CODE.QTY_LESS_THAN_MINIMUM }], + failure: [{ errorCode: API_ERROR_CODE.QTY_LESS_THAN_MINIMUM_SPOT }], }, }); } catch (e) { + // console.log(`fn() exception: `, e.body); + expect(e).toBeNull(); } });