Merge pull request #1 from tiagosiebler/collab/promiseonws

chore(): fix flaky test
This commit is contained in:
Caius Citiriga
2023-05-17 17:17:19 +02:00
committed by GitHub
2 changed files with 20 additions and 16 deletions

View File

@@ -20,7 +20,7 @@ describe('Public V5 REST API Endpoints', () => {
it('getServerTime()', async () => { it('getServerTime()', async () => {
expect(await api.getServerTime()).toMatchObject( expect(await api.getServerTime()).toMatchObject(
successResponseObjectV3() successResponseObjectV3(),
); );
}); });
}); });
@@ -32,7 +32,7 @@ describe('Public V5 REST API Endpoints', () => {
category: 'linear', category: 'linear',
interval: '1', interval: '1',
symbol: linearSymbol, symbol: linearSymbol,
}) }),
).toMatchObject(successResponseObjectV3()); ).toMatchObject(successResponseObjectV3());
}); });
@@ -42,7 +42,7 @@ describe('Public V5 REST API Endpoints', () => {
category: 'linear', category: 'linear',
interval: '1', interval: '1',
symbol: linearSymbol, symbol: linearSymbol,
}) }),
).toMatchObject(successResponseObjectV3()); ).toMatchObject(successResponseObjectV3());
}); });
@@ -52,7 +52,7 @@ describe('Public V5 REST API Endpoints', () => {
category: 'linear', category: 'linear',
interval: '1', interval: '1',
symbol: linearSymbol, symbol: linearSymbol,
}) }),
).toMatchObject(successResponseObjectV3()); ).toMatchObject(successResponseObjectV3());
}); });
@@ -62,7 +62,7 @@ describe('Public V5 REST API Endpoints', () => {
category: 'linear', category: 'linear',
interval: '1', interval: '1',
symbol: linearSymbol, symbol: linearSymbol,
}) }),
).toMatchObject(successResponseObjectV3()); ).toMatchObject(successResponseObjectV3());
}); });
@@ -71,7 +71,7 @@ describe('Public V5 REST API Endpoints', () => {
await api.getInstrumentsInfo({ await api.getInstrumentsInfo({
category: 'linear', category: 'linear',
symbol: linearSymbol, symbol: linearSymbol,
}) }),
).toMatchObject(successResponseObjectV3()); ).toMatchObject(successResponseObjectV3());
}); });
@@ -80,7 +80,7 @@ describe('Public V5 REST API Endpoints', () => {
await api.getOrderbook({ await api.getOrderbook({
category: 'linear', category: 'linear',
symbol: linearSymbol, symbol: linearSymbol,
}) }),
).toMatchObject(successResponseObjectV3()); ).toMatchObject(successResponseObjectV3());
}); });
@@ -89,7 +89,7 @@ describe('Public V5 REST API Endpoints', () => {
await api.getTickers({ await api.getTickers({
category: 'linear', category: 'linear',
symbol: linearSymbol, symbol: linearSymbol,
}) }),
).toMatchObject(successResponseObjectV3()); ).toMatchObject(successResponseObjectV3());
}); });
@@ -98,7 +98,7 @@ describe('Public V5 REST API Endpoints', () => {
await api.getFundingRateHistory({ await api.getFundingRateHistory({
category: 'linear', category: 'linear',
symbol: linearSymbol, symbol: linearSymbol,
}) }),
).toMatchObject(successResponseObjectV3()); ).toMatchObject(successResponseObjectV3());
}); });
@@ -107,8 +107,12 @@ describe('Public V5 REST API Endpoints', () => {
await api.getPublicTradingHistory({ await api.getPublicTradingHistory({
category: 'linear', category: 'linear',
symbol: linearSymbol, symbol: linearSymbol,
}) }),
).toMatchObject(successResponseObjectV3()); ).toMatchObject({
...successResponseObjectV3(),
retMsg: 'OK',
retCode: 0,
});
}); });
it('getOpenInterest()', async () => { it('getOpenInterest()', async () => {
@@ -117,7 +121,7 @@ describe('Public V5 REST API Endpoints', () => {
category: 'linear', category: 'linear',
symbol: linearSymbol, symbol: linearSymbol,
intervalTime: '15min', intervalTime: '15min',
}) }),
).toMatchObject(successResponseObjectV3()); ).toMatchObject(successResponseObjectV3());
}); });
@@ -125,7 +129,7 @@ describe('Public V5 REST API Endpoints', () => {
expect( expect(
await api.getHistoricalVolatility({ await api.getHistoricalVolatility({
category: 'option', category: 'option',
}) }),
).toMatchObject(successResponseObjectV3()); ).toMatchObject(successResponseObjectV3());
}); });
@@ -138,7 +142,7 @@ describe('Public V5 REST API Endpoints', () => {
await api.getRiskLimit({ await api.getRiskLimit({
category: 'linear', category: 'linear',
symbol: linearSymbol, symbol: linearSymbol,
}) }),
).toMatchObject(successResponseObjectV3()); ).toMatchObject(successResponseObjectV3());
}); });
@@ -146,7 +150,7 @@ describe('Public V5 REST API Endpoints', () => {
expect( expect(
await api.getOptionDeliveryPrice({ await api.getOptionDeliveryPrice({
category: 'option', category: 'option',
}) }),
).toMatchObject(successResponseObjectV3()); ).toMatchObject(successResponseObjectV3());
}); });
}); });

View File

@@ -20,7 +20,7 @@ describe('Public V5 Websocket client', () => {
await api.subscribeV5(`publicTrade.${linearSymbol}X`, linearCategory); await api.subscribeV5(`publicTrade.${linearSymbol}X`, linearCategory);
} catch (e) { } catch (e) {
expect(e).toBeDefined(); expect(e).toBeDefined();
expect(e).toMatch('(publicTrade.BTCUSDT) failed to subscribe'); expect(e).toMatch(`(publicTrade.${linearSymbol}X) failed to subscribe`);
} }
}); });
}); });