forked from ovotech/bit-node-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintegration.spec.ts
More file actions
21 lines (17 loc) · 869 Bytes
/
Copy pathintegration.spec.ts
File metadata and controls
21 lines (17 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { ObjectWritableMock } from 'stream-mock';
import { createLogger, transports } from 'winston';
import { Logger } from '../src';
describe('Integration test', () => {
it('Test with real stream', async () => {
const stream = new ObjectWritableMock();
const transport = new transports.Stream({ stream });
const winstonLogger = createLogger({ exitOnError: false, transports: [transport] });
const logger = new Logger(winstonLogger, { test1: 'test1' });
logger.error('send test', { test2: 'test2' });
logger.info('other test', { test3: 'test3' });
expect(stream.data).toEqual([
expect.objectContaining({ message: 'send test', metadata: { test2: 'test2', test1: 'test1' }, level: 'error' }),
expect.objectContaining({ message: 'other test', metadata: { test3: 'test3', test1: 'test1' }, level: 'info' }),
]);
});
});