Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' into style/fix-fromatting
Browse files Browse the repository at this point in the history
  • Loading branch information
smolijar committed Nov 22, 2019
2 parents 4ae7503 + f497683 commit e32b79f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
12 changes: 1 addition & 11 deletions src/tests/express.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'jest-extended';
import { Writable } from 'stream';
import * as supertest from 'supertest';
import { levels } from '../levels';
import { testWriteStream } from './utils';

let loggerFactory;

Expand All @@ -11,17 +12,6 @@ beforeEach(() => {
loggerFactory = require('..').default;
});

const testWriteStream = (resolve, assert) => ({
stream: new Writable({
write: (chunk, encoding, next) => {
const json = JSON.parse(chunk);
assert(json);
next();
resolve();
},
}),
});

test('express binds', () => {
const logger = loggerFactory();
const app = express();
Expand Down
12 changes: 1 addition & 11 deletions src/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import isString = require('lodash.isstring');
import { Writable } from 'stream';
import loggerFactory, { pkgVersionKey, loggerNameKey } from '..';
import { levels } from '../levels';
import { testWriteStream } from './utils';

test('can create default logger', () => {
const logger = loggerFactory();
Expand All @@ -21,17 +22,6 @@ test('can create logger with options', () => {
expect(logger.options.pretty).toBe(true);
});

const testWriteStream = (resolve, assert, isJson = true) => ({
stream: new Writable({
write: (chunk, encoding, next) => {
const json = isJson ? JSON.parse(chunk) : chunk.toString();
assert(json);
next();
resolve();
},
}),
});

test('can use custom stream', () =>
new Promise((resolve, reject) => {
const logger = loggerFactory({
Expand Down
12 changes: 12 additions & 0 deletions src/tests/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Writable } from 'stream';

export const testWriteStream = (resolve, assert, isJson = true) => ({
stream: new Writable({
write: (chunk, encoding, next) => {
const json = isJson ? JSON.parse(chunk) : chunk.toString();
assert(json);
next();
resolve();
},
}),
});

0 comments on commit e32b79f

Please sign in to comment.