chore(): lint for trailing commas, fix tests with new types

This commit is contained in:
Tiago Siebler
2023-03-22 17:02:12 +00:00
parent 831689e857
commit e9972ef829
20 changed files with 86 additions and 85 deletions

View File

@@ -27,7 +27,7 @@ describe('Private Broker REST API GET Endpoints', () => {
it('getBrokerInfo()', async () => {
try {
expect(await api.getBrokerInfo()).toMatchObject(
sucessEmptyResponseObject()
sucessEmptyResponseObject(),
);
} catch (e) {
expect(e.body).toMatchObject({
@@ -39,7 +39,7 @@ describe('Private Broker REST API GET Endpoints', () => {
it('getSubAccounts()', async () => {
try {
expect(await api.getSubAccounts()).toMatchObject(
sucessEmptyResponseObject()
sucessEmptyResponseObject(),
);
} catch (e) {
expect(e.body).toMatchObject({
@@ -51,7 +51,7 @@ describe('Private Broker REST API GET Endpoints', () => {
it('getSubEmail()', async () => {
try {
expect(await api.getSubEmail(subUid)).toMatchObject(
sucessEmptyResponseObject()
sucessEmptyResponseObject(),
);
} catch (e) {
expect(e.body).toMatchObject({
@@ -63,7 +63,7 @@ describe('Private Broker REST API GET Endpoints', () => {
it('getSubSpotAssets()', async () => {
try {
expect(await api.getSubSpotAssets(subUid)).toMatchObject(
sucessEmptyResponseObject()
sucessEmptyResponseObject(),
);
} catch (e) {
// expect(e.body).toBeNull();
@@ -76,7 +76,7 @@ describe('Private Broker REST API GET Endpoints', () => {
it('getSubFutureAssets()', async () => {
try {
expect(await api.getSubFutureAssets(subUid, 'usdt')).toMatchObject(
sucessEmptyResponseObject()
sucessEmptyResponseObject(),
);
} catch (e) {
expect(e.body).toMatchObject({
@@ -88,7 +88,7 @@ describe('Private Broker REST API GET Endpoints', () => {
it('getSubDepositAddress()', async () => {
try {
expect(await api.getSubDepositAddress(subUid, coin)).toMatchObject(
sucessEmptyResponseObject()
sucessEmptyResponseObject(),
);
} catch (e) {
expect(e.body).toMatchObject({
@@ -100,7 +100,7 @@ describe('Private Broker REST API GET Endpoints', () => {
it('getSubAPIKeys()', async () => {
try {
expect(await api.getSubAPIKeys(subUid)).toMatchObject(
sucessEmptyResponseObject()
sucessEmptyResponseObject(),
);
} catch (e) {
expect(e.body).toMatchObject({

View File

@@ -27,7 +27,7 @@ describe('Private Broker REST API POST Endpoints', () => {
it('createSubAccount()', async () => {
try {
expect(await api.createSubAccount('test1')).toMatchObject(
sucessEmptyResponseObject()
sucessEmptyResponseObject(),
);
} catch (e) {
expect(e.body).toMatchObject({
@@ -39,7 +39,7 @@ describe('Private Broker REST API POST Endpoints', () => {
it('modifySubAccount()', async () => {
try {
expect(
await api.modifySubAccount('test1', 'spot_trade,transfer', 'normal')
await api.modifySubAccount('test1', 'spot_trade,transfer', 'normal'),
).toMatchObject(sucessEmptyResponseObject());
} catch (e) {
expect(e.body).toMatchObject({
@@ -51,7 +51,7 @@ describe('Private Broker REST API POST Endpoints', () => {
it('modifySubEmail()', async () => {
try {
expect(
await api.modifySubEmail('test1', 'ASDFASDF@LKMASDF.COM')
await api.modifySubEmail('test1', 'ASDFASDF@LKMASDF.COM'),
).toMatchObject(sucessEmptyResponseObject());
} catch (e) {
expect(e.body).toMatchObject({
@@ -69,7 +69,7 @@ describe('Private Broker REST API POST Endpoints', () => {
chain: 'TRC20',
coin: 'USDT',
subUid,
})
}),
).toMatchObject(sucessEmptyResponseObject());
} catch (e) {
expect(e.body).toMatchObject({
@@ -81,7 +81,7 @@ describe('Private Broker REST API POST Endpoints', () => {
it('setSubDepositAutoTransfer()', async () => {
try {
expect(
await api.setSubDepositAutoTransfer(subUid, 'USDT', 'spot')
await api.setSubDepositAutoTransfer(subUid, 'USDT', 'spot'),
).toMatchObject(sucessEmptyResponseObject());
} catch (e) {
expect(e.body).toMatchObject({
@@ -97,8 +97,8 @@ describe('Private Broker REST API POST Endpoints', () => {
subUid,
'passphrase12345',
'remark',
'10.0.0.1'
)
'10.0.0.1',
),
).toMatchObject(sucessEmptyResponseObject());
} catch (e) {
expect(e.body).toMatchObject({
@@ -114,7 +114,7 @@ describe('Private Broker REST API POST Endpoints', () => {
apikey: '12345',
subUid,
remark: 'test',
})
}),
).toMatchObject(sucessEmptyResponseObject());
} catch (e) {
expect(e.body).toMatchObject({

View File

@@ -57,7 +57,7 @@ describe('Private Futures REST API GET Endpoints', () => {
it('getOpenCount()', async () => {
try {
expect(
await api.getOpenCount(symbol, marginCoin, 20000, 1)
await api.getOpenCount(symbol, marginCoin, 20000, 1),
).toMatchObject({
...sucessEmptyResponseObject(),
data: {
@@ -102,7 +102,7 @@ describe('Private Futures REST API GET Endpoints', () => {
endTime: to,
marginCoin,
symbol,
})
}),
).toMatchObject({
...sucessEmptyResponseObject(),
data: {
@@ -125,7 +125,7 @@ describe('Private Futures REST API GET Endpoints', () => {
startTime: from,
endTime: to,
productType: 'umcbl',
})
}),
).toMatchObject({
...sucessEmptyResponseObject(),
data: {
@@ -180,7 +180,7 @@ describe('Private Futures REST API GET Endpoints', () => {
it('getProductTypeOrderHistory()', async () => {
try {
expect(
await api.getProductTypeOrderHistory('umcbl', from, to, '10')
await api.getProductTypeOrderHistory('umcbl', from, to, '10'),
).toMatchObject({
...sucessEmptyResponseObject(),
data: expect.any(Object),
@@ -223,7 +223,7 @@ describe('Private Futures REST API GET Endpoints', () => {
await api.getProductTypeOrderFills('umcbl', {
startTime: from,
endTime: to,
})
}),
).toMatchObject({
...sucessEmptyResponseObject(),
data: expect.any(Object),
@@ -253,7 +253,7 @@ describe('Private Futures REST API GET Endpoints', () => {
startTime: from,
endTime: to,
symbol,
})
}),
).toMatchObject({
...sucessEmptyResponseObject(),
data: expect.any(Object),
@@ -267,7 +267,7 @@ describe('Private Futures REST API GET Endpoints', () => {
it('getCopyTraderOpenOrder()', async () => {
try {
expect(
await api.getCopyTraderOpenOrder(symbol, 'umcbl', 1, 0)
await api.getCopyTraderOpenOrder(symbol, 'umcbl', 1, 0),
).toMatchObject({
...sucessEmptyResponseObject(),
data: expect.any(Object),
@@ -282,7 +282,7 @@ describe('Private Futures REST API GET Endpoints', () => {
it('getCopyFollowersOpenOrder()', async () => {
try {
expect(
await api.getCopyFollowersOpenOrder(symbol, 'umcbl', 1, 0)
await api.getCopyFollowersOpenOrder(symbol, 'umcbl', 1, 0),
).toMatchObject({
...sucessEmptyResponseObject(),
data: expect.any(Object),
@@ -300,7 +300,7 @@ describe('Private Futures REST API GET Endpoints', () => {
{
...sucessEmptyResponseObject(),
data: expect.any(Object),
}
},
);
} catch (e) {
expect(e.body).toMatchObject({
@@ -342,8 +342,8 @@ describe('Private Futures REST API GET Endpoints', () => {
marginCoin,
from,
1,
1
)
1,
),
).toMatchObject({
...sucessEmptyResponseObject(),
data: expect.any(Object),
@@ -358,7 +358,7 @@ describe('Private Futures REST API GET Endpoints', () => {
it('getCopyTraderHistoricProfitDetail()', async () => {
try {
expect(
await api.getCopyTraderHistoricProfitDetail(marginCoin, from, 1, 1)
await api.getCopyTraderHistoricProfitDetail(marginCoin, from, 1, 1),
).toMatchObject({
...sucessEmptyResponseObject(),
data: expect.any(Object),

View File

@@ -53,7 +53,7 @@ describe('Private Futures REST API POST Endpoints', () => {
it('setMarginMode()', async () => {
try {
expect(
await api.setMarginMode(symbol, marginCoin, 'crossed')
await api.setMarginMode(symbol, marginCoin, 'crossed'),
).toMatchObject({
...sucessEmptyResponseObject(),
data: {},
@@ -76,7 +76,7 @@ describe('Private Futures REST API POST Endpoints', () => {
symbol,
size: '1',
side: 'open_long',
})
}),
).toMatchObject({
...sucessEmptyResponseObject(),
data: {},
@@ -100,7 +100,7 @@ describe('Private Futures REST API POST Endpoints', () => {
size: '1',
side: 'open_long',
},
])
]),
).toMatchObject({
...sucessEmptyResponseObject(),
data: {},
@@ -115,7 +115,7 @@ describe('Private Futures REST API POST Endpoints', () => {
it('cancelOrder()', async () => {
try {
expect(
await api.cancelOrder(symbol, marginCoin, '1234656')
await api.cancelOrder(symbol, marginCoin, '1234656'),
).toMatchObject({
...sucessEmptyResponseObject(),
data: {},
@@ -130,7 +130,7 @@ describe('Private Futures REST API POST Endpoints', () => {
it('batchCancelOrder()', async () => {
try {
expect(
await api.batchCancelOrder(symbol, marginCoin, ['1234656'])
await api.batchCancelOrder(symbol, marginCoin, ['1234656']),
).toMatchObject({
...sucessEmptyResponseObject(),
data: {},
@@ -164,7 +164,7 @@ describe('Private Futures REST API POST Endpoints', () => {
symbol,
triggerPrice: '1000',
triggerType: 'market_price',
})
}),
).toMatchObject({
...sucessEmptyResponseObject(),
data: {},
@@ -187,7 +187,7 @@ describe('Private Futures REST API POST Endpoints', () => {
symbol,
triggerPrice: '100',
triggerType: 'market_price',
})
}),
).toMatchObject({
...sucessEmptyResponseObject(),
data: {},
@@ -207,7 +207,7 @@ describe('Private Futures REST API POST Endpoints', () => {
marginCoin,
symbol,
presetTakeProfitPrice: '100',
})
}),
).toMatchObject({
...sucessEmptyResponseObject(),
data: {},
@@ -229,7 +229,7 @@ describe('Private Futures REST API POST Endpoints', () => {
planType: 'profit_plan',
holdSide: 'long',
triggerPrice: '100',
})
}),
).toMatchObject({
...sucessEmptyResponseObject(),
data: {},
@@ -251,7 +251,7 @@ describe('Private Futures REST API POST Endpoints', () => {
holdSide: 'long',
planType: 'profit_plan',
triggerPrice: '50',
})
}),
).toMatchObject({
...sucessEmptyResponseObject(),
data: {},
@@ -270,7 +270,8 @@ describe('Private Futures REST API POST Endpoints', () => {
marginCoin,
symbol,
orderId: '123456',
})
planType: 'profit_plan',
}),
).toMatchObject({
...sucessEmptyResponseObject(),
data: {},
@@ -292,7 +293,7 @@ describe('Private Futures REST API POST Endpoints', () => {
symbol,
orderId: '123456',
planType: 'profit_plan',
})
}),
).toMatchObject({
...sucessEmptyResponseObject(),
data: {},
@@ -310,7 +311,7 @@ describe('Private Futures REST API POST Endpoints', () => {
{
...sucessEmptyResponseObject(),
data: {},
}
},
);
} catch (e) {
expect(e.body).toMatchObject({
@@ -324,7 +325,7 @@ describe('Private Futures REST API POST Endpoints', () => {
expect(
await api.modifyCopyTraderTPSL(symbol, '123456', {
stopLossPrice: 1234,
})
}),
).toMatchObject({
...sucessEmptyResponseObject(),
data: {},

View File

@@ -70,7 +70,7 @@ describe('Public Spot REST API Endpoints', () => {
it('getCandles()', async () => {
expect(
await api.getCandles(symbol, '1min', `${from}`, `${to}`)
await api.getCandles(symbol, '1min', `${from}`, `${to}`),
).toMatchObject(expect.any(Array));
});

View File

@@ -19,7 +19,7 @@ export function sucessEmptyResponseObject() {
export function errorResponseObject(
result: null | any = null,
ret_code: number,
ret_msg: string
ret_msg: string,
) {
return {
result,
@@ -30,7 +30,7 @@ export function errorResponseObject(
export function errorResponseObjectV3(
result: null | any = null,
retCode: number
retCode: number,
) {
return {
result,

View File

@@ -26,7 +26,7 @@ describe('Private Spot Websocket Client', () => {
apiSecret: 'bad',
apiPass: 'bad',
},
getSilentLogger('expect401')
getSilentLogger('expect401'),
);
// const wsOpenPromise = waitForSocketEvent(badClient, 'open');
@@ -62,7 +62,7 @@ describe('Private Spot Websocket Client', () => {
beforeAll(() => {
wsClient = new WebsocketClient(
wsClientOptions,
getSilentLogger('expectSuccess')
getSilentLogger('expectSuccess'),
);
wsClient.connectAll();
// logAllEvents(wsClient);

View File

@@ -13,7 +13,7 @@ describe('Public Spot Websocket Client', () => {
beforeAll(() => {
wsClient = new WebsocketClient(
wsClientOptions,
getSilentLogger('expectSuccess')
getSilentLogger('expectSuccess'),
);
wsClient.connectAll();
logAllEvents(wsClient);

View File

@@ -24,12 +24,12 @@ export const fullLogger = {
export function waitForSocketEvent(
wsClient: WebsocketClient,
event: WsClientEvent,
timeoutMs: number = 4.5 * 1000
timeoutMs: number = 4.5 * 1000,
) {
return new Promise((resolve, reject) => {
const timeout = setTimeout(() => {
reject(
`Failed to receive "${event}" event before timeout. Check that these are correct: topic, api keys (if private), signature process (if private)`
`Failed to receive "${event}" event before timeout. Check that these are correct: topic, api keys (if private), signature process (if private)`,
);
}, timeoutMs);