From a9dd6face97912f51f39d13f0c5aeda8ac96dc35 Mon Sep 17 00:00:00 2001 From: tiagosiebler Date: Fri, 16 Sep 2022 00:51:18 +0100 Subject: [PATCH] slight logger improvement for test --- test/inverse/ws.private.test.ts | 9 ++++++--- test/linear/ws.private.test.ts | 9 ++++++--- test/spot/ws.private.v1.test.ts | 7 +++++-- test/spot/ws.private.v3.test.ts | 9 ++++++--- test/spot/ws.public.v1.test.ts | 7 +++++-- test/spot/ws.public.v3.test.ts | 7 +++++-- test/ws.util.ts | 18 ++++++++++-------- 7 files changed, 43 insertions(+), 23 deletions(-) diff --git a/test/inverse/ws.private.test.ts b/test/inverse/ws.private.test.ts index 1c8fb2d..c95a3b5 100644 --- a/test/inverse/ws.private.test.ts +++ b/test/inverse/ws.private.test.ts @@ -4,7 +4,7 @@ import { WS_KEY_MAP, } from '../../src'; import { - silentLogger, + getSilentLogger, waitForSocketEvent, WS_OPEN_EVENT_PARTIAL, } from '../ws.util'; @@ -27,7 +27,7 @@ describe('Private Inverse Perps Websocket Client', () => { key: 'bad', secret: 'bad', }, - silentLogger + getSilentLogger('expect401') ); const wsOpenPromise = waitForSocketEvent(badClient, 'open', 2500); @@ -53,7 +53,10 @@ describe('Private Inverse Perps Websocket Client', () => { }); beforeAll(() => { - wsClient = new WebsocketClient(wsClientOptions, silentLogger); + wsClient = new WebsocketClient( + wsClientOptions, + getSilentLogger('expectSuccess') + ); wsClient.connectPrivate(); }); diff --git a/test/linear/ws.private.test.ts b/test/linear/ws.private.test.ts index 8e8cecf..1f9336f 100644 --- a/test/linear/ws.private.test.ts +++ b/test/linear/ws.private.test.ts @@ -4,7 +4,7 @@ import { WS_KEY_MAP, } from '../../src'; import { - silentLogger, + getSilentLogger, waitForSocketEvent, WS_OPEN_EVENT_PARTIAL, } from '../ws.util'; @@ -27,7 +27,7 @@ describe('Private Linear Perps Websocket Client', () => { key: 'bad', secret: 'bad', }, - silentLogger + getSilentLogger('expect401') ); const wsOpenPromise = waitForSocketEvent(badClient, 'open', 2500); @@ -58,7 +58,10 @@ describe('Private Linear Perps Websocket Client', () => { }; beforeAll(() => { - wsClient = new WebsocketClient(wsClientOptions, silentLogger); + wsClient = new WebsocketClient( + wsClientOptions, + getSilentLogger('expectSuccess') + ); wsClient.connectPrivate(); }); diff --git a/test/spot/ws.private.v1.test.ts b/test/spot/ws.private.v1.test.ts index 8242c61..3cb62f3 100644 --- a/test/spot/ws.private.v1.test.ts +++ b/test/spot/ws.private.v1.test.ts @@ -6,7 +6,7 @@ import { import { logAllEvents, promiseSleep, - silentLogger, + getSilentLogger, waitForSocketEvent, WS_OPEN_EVENT_PARTIAL, } from '../ws.util'; @@ -28,7 +28,10 @@ describe('Private Spot V1 Websocket Client', () => { }; beforeAll(() => { - wsClient = new WebsocketClient(wsClientOptions, silentLogger); + wsClient = new WebsocketClient( + wsClientOptions, + getSilentLogger('expectSuccess') + ); logAllEvents(wsClient); }); diff --git a/test/spot/ws.private.v3.test.ts b/test/spot/ws.private.v3.test.ts index f867f1e..b430b29 100644 --- a/test/spot/ws.private.v3.test.ts +++ b/test/spot/ws.private.v3.test.ts @@ -5,7 +5,7 @@ import { WS_KEY_MAP, } from '../../src'; import { - silentLogger, + getSilentLogger, waitForSocketEvent, WS_OPEN_EVENT_PARTIAL, } from '../ws.util'; @@ -29,7 +29,7 @@ describe('Private Spot V3 Websocket Client', () => { key: 'bad', secret: 'bad', }, - silentLogger + getSilentLogger('expect401') ); // const wsOpenPromise = waitForSocketEvent(badClient, 'open'); @@ -63,7 +63,10 @@ describe('Private Spot V3 Websocket Client', () => { }); beforeAll(() => { - wsClient = new WebsocketClient(wsClientOptions, silentLogger); + wsClient = new WebsocketClient( + wsClientOptions, + getSilentLogger('expectSuccess') + ); wsClient.connectPrivate(); // logAllEvents(wsClient); }); diff --git a/test/spot/ws.public.v1.test.ts b/test/spot/ws.public.v1.test.ts index a17a32c..cdb48d4 100644 --- a/test/spot/ws.public.v1.test.ts +++ b/test/spot/ws.public.v1.test.ts @@ -5,7 +5,7 @@ import { } from '../../src'; import { logAllEvents, - silentLogger, + getSilentLogger, fullLogger, waitForSocketEvent, WS_OPEN_EVENT_PARTIAL, @@ -19,7 +19,10 @@ describe('Public Spot V1 Websocket Client', () => { }; beforeAll(() => { - wsClient = new WebsocketClient(wsClientOptions, silentLogger); + wsClient = new WebsocketClient( + wsClientOptions, + getSilentLogger('expectSuccess') + ); wsClient.connectPublic(); // logAllEvents(wsClient); }); diff --git a/test/spot/ws.public.v3.test.ts b/test/spot/ws.public.v3.test.ts index 8fe07b0..0cd86f1 100644 --- a/test/spot/ws.public.v3.test.ts +++ b/test/spot/ws.public.v3.test.ts @@ -5,7 +5,7 @@ import { } from '../../src'; import { logAllEvents, - silentLogger, + getSilentLogger, fullLogger, waitForSocketEvent, WS_OPEN_EVENT_PARTIAL, @@ -19,7 +19,10 @@ describe('Public Spot V3 Websocket Client', () => { }; beforeAll(() => { - wsClient = new WebsocketClient(wsClientOptions, silentLogger); + wsClient = new WebsocketClient( + wsClientOptions, + getSilentLogger('expectSuccess') + ); wsClient.connectPublic(); // logAllEvents(wsClient); }); diff --git a/test/ws.util.ts b/test/ws.util.ts index 5cb4bc5..952e9fc 100644 --- a/test/ws.util.ts +++ b/test/ws.util.ts @@ -1,13 +1,15 @@ import { WebsocketClient, WsClientEvent } from '../src'; -export const silentLogger = { - silly: () => {}, - debug: () => {}, - notice: () => {}, - info: () => {}, - warning: (...params) => console.warn('warning', ...params), - error: (...params) => console.error('error', ...params), -}; +export function getSilentLogger(logHint?: string) { + return { + silly: () => {}, + debug: () => {}, + notice: () => {}, + info: () => {}, + warning: (...params) => console.warn('warning', logHint, ...params), + error: (...params) => console.error('error', logHint, ...params), + }; +} export const fullLogger = { silly: (...params) => console.log('silly', ...params),