Skip to content

Commit

Permalink
test(log): delaying logs folder check
Browse files Browse the repository at this point in the history
  • Loading branch information
reel committed Jul 12, 2017
1 parent 4f1a0b6 commit 0938ff4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/log/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ log.add(winston.transports.Console, {
const fullMsg = `${title} ${message || meta}`;
let space =
process.stdout.columns - stringWidth(fullMsg) - stringWidth(dateString);
/* istanbul ignore if */
if (space <= 0) {
space = 10;
}
Expand Down
10 changes: 7 additions & 3 deletions packages/log/tests/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const path = require('path');
const fs = require('fs');

describe('log', () => {
beforeEach(() => {
beforeAll(async () => {
process.env.ALLOW_CONFIG_MUTATIONS = true;
const logsDirecory = path.resolve(process.cwd(), 'logs');
if (!fs.existsSync(logsDirecory)) {
Expand All @@ -17,14 +17,18 @@ describe('log', () => {
test('log to console', () => {
expect(henri.log.transports.console).toBeDefined();
});
test('should log to a file', () => {
test('should log to a file', done => {
const filename = path.resolve(
process.cwd(),
'logs',
`${henri.config.get('log')}`
);
expect(fs.existsSync(filename)).toBe(true);
expect(henri.log.transports.file).toBeDefined();
setTimeout(() => {
if (fs.existsSync(filename)) {
done();
}
}, 500);
});
test('notify', () => {
expect(henri.notify).toBeDefined();
Expand Down

0 comments on commit 0938ff4

Please sign in to comment.