slight logger improvement for test

This commit is contained in:
tiagosiebler
2022-09-16 00:51:18 +01:00
parent bd09cf8109
commit a9dd6face9
7 changed files with 43 additions and 23 deletions

View File

@@ -4,7 +4,7 @@ import {
WS_KEY_MAP, WS_KEY_MAP,
} from '../../src'; } from '../../src';
import { import {
silentLogger, getSilentLogger,
waitForSocketEvent, waitForSocketEvent,
WS_OPEN_EVENT_PARTIAL, WS_OPEN_EVENT_PARTIAL,
} from '../ws.util'; } from '../ws.util';
@@ -27,7 +27,7 @@ describe('Private Inverse Perps Websocket Client', () => {
key: 'bad', key: 'bad',
secret: 'bad', secret: 'bad',
}, },
silentLogger getSilentLogger('expect401')
); );
const wsOpenPromise = waitForSocketEvent(badClient, 'open', 2500); const wsOpenPromise = waitForSocketEvent(badClient, 'open', 2500);
@@ -53,7 +53,10 @@ describe('Private Inverse Perps Websocket Client', () => {
}); });
beforeAll(() => { beforeAll(() => {
wsClient = new WebsocketClient(wsClientOptions, silentLogger); wsClient = new WebsocketClient(
wsClientOptions,
getSilentLogger('expectSuccess')
);
wsClient.connectPrivate(); wsClient.connectPrivate();
}); });

View File

@@ -4,7 +4,7 @@ import {
WS_KEY_MAP, WS_KEY_MAP,
} from '../../src'; } from '../../src';
import { import {
silentLogger, getSilentLogger,
waitForSocketEvent, waitForSocketEvent,
WS_OPEN_EVENT_PARTIAL, WS_OPEN_EVENT_PARTIAL,
} from '../ws.util'; } from '../ws.util';
@@ -27,7 +27,7 @@ describe('Private Linear Perps Websocket Client', () => {
key: 'bad', key: 'bad',
secret: 'bad', secret: 'bad',
}, },
silentLogger getSilentLogger('expect401')
); );
const wsOpenPromise = waitForSocketEvent(badClient, 'open', 2500); const wsOpenPromise = waitForSocketEvent(badClient, 'open', 2500);
@@ -58,7 +58,10 @@ describe('Private Linear Perps Websocket Client', () => {
}; };
beforeAll(() => { beforeAll(() => {
wsClient = new WebsocketClient(wsClientOptions, silentLogger); wsClient = new WebsocketClient(
wsClientOptions,
getSilentLogger('expectSuccess')
);
wsClient.connectPrivate(); wsClient.connectPrivate();
}); });

View File

@@ -6,7 +6,7 @@ import {
import { import {
logAllEvents, logAllEvents,
promiseSleep, promiseSleep,
silentLogger, getSilentLogger,
waitForSocketEvent, waitForSocketEvent,
WS_OPEN_EVENT_PARTIAL, WS_OPEN_EVENT_PARTIAL,
} from '../ws.util'; } from '../ws.util';
@@ -28,7 +28,10 @@ describe('Private Spot V1 Websocket Client', () => {
}; };
beforeAll(() => { beforeAll(() => {
wsClient = new WebsocketClient(wsClientOptions, silentLogger); wsClient = new WebsocketClient(
wsClientOptions,
getSilentLogger('expectSuccess')
);
logAllEvents(wsClient); logAllEvents(wsClient);
}); });

View File

@@ -5,7 +5,7 @@ import {
WS_KEY_MAP, WS_KEY_MAP,
} from '../../src'; } from '../../src';
import { import {
silentLogger, getSilentLogger,
waitForSocketEvent, waitForSocketEvent,
WS_OPEN_EVENT_PARTIAL, WS_OPEN_EVENT_PARTIAL,
} from '../ws.util'; } from '../ws.util';
@@ -29,7 +29,7 @@ describe('Private Spot V3 Websocket Client', () => {
key: 'bad', key: 'bad',
secret: 'bad', secret: 'bad',
}, },
silentLogger getSilentLogger('expect401')
); );
// const wsOpenPromise = waitForSocketEvent(badClient, 'open'); // const wsOpenPromise = waitForSocketEvent(badClient, 'open');
@@ -63,7 +63,10 @@ describe('Private Spot V3 Websocket Client', () => {
}); });
beforeAll(() => { beforeAll(() => {
wsClient = new WebsocketClient(wsClientOptions, silentLogger); wsClient = new WebsocketClient(
wsClientOptions,
getSilentLogger('expectSuccess')
);
wsClient.connectPrivate(); wsClient.connectPrivate();
// logAllEvents(wsClient); // logAllEvents(wsClient);
}); });

View File

@@ -5,7 +5,7 @@ import {
} from '../../src'; } from '../../src';
import { import {
logAllEvents, logAllEvents,
silentLogger, getSilentLogger,
fullLogger, fullLogger,
waitForSocketEvent, waitForSocketEvent,
WS_OPEN_EVENT_PARTIAL, WS_OPEN_EVENT_PARTIAL,
@@ -19,7 +19,10 @@ describe('Public Spot V1 Websocket Client', () => {
}; };
beforeAll(() => { beforeAll(() => {
wsClient = new WebsocketClient(wsClientOptions, silentLogger); wsClient = new WebsocketClient(
wsClientOptions,
getSilentLogger('expectSuccess')
);
wsClient.connectPublic(); wsClient.connectPublic();
// logAllEvents(wsClient); // logAllEvents(wsClient);
}); });

View File

@@ -5,7 +5,7 @@ import {
} from '../../src'; } from '../../src';
import { import {
logAllEvents, logAllEvents,
silentLogger, getSilentLogger,
fullLogger, fullLogger,
waitForSocketEvent, waitForSocketEvent,
WS_OPEN_EVENT_PARTIAL, WS_OPEN_EVENT_PARTIAL,
@@ -19,7 +19,10 @@ describe('Public Spot V3 Websocket Client', () => {
}; };
beforeAll(() => { beforeAll(() => {
wsClient = new WebsocketClient(wsClientOptions, silentLogger); wsClient = new WebsocketClient(
wsClientOptions,
getSilentLogger('expectSuccess')
);
wsClient.connectPublic(); wsClient.connectPublic();
// logAllEvents(wsClient); // logAllEvents(wsClient);
}); });

View File

@@ -1,13 +1,15 @@
import { WebsocketClient, WsClientEvent } from '../src'; import { WebsocketClient, WsClientEvent } from '../src';
export const silentLogger = { export function getSilentLogger(logHint?: string) {
return {
silly: () => {}, silly: () => {},
debug: () => {}, debug: () => {},
notice: () => {}, notice: () => {},
info: () => {}, info: () => {},
warning: (...params) => console.warn('warning', ...params), warning: (...params) => console.warn('warning', logHint, ...params),
error: (...params) => console.error('error', ...params), error: (...params) => console.error('error', logHint, ...params),
}; };
}
export const fullLogger = { export const fullLogger = {
silly: (...params) => console.log('silly', ...params), silly: (...params) => console.log('silly', ...params),