Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f51969
commit bce6e98
Showing
2 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import * as services from '../service'; | ||
import Level from '../enum/level'; | ||
|
||
describe('logger', () => { | ||
let Logger; | ||
|
||
beforeAll(() => { | ||
process.env.LOG_LEVEL = 'WARN'; | ||
Logger = require('../logger').default; | ||
}); | ||
|
||
afterAll(() => { | ||
delete process.env.LOG_LEVEL; | ||
}); | ||
|
||
it('should accept process.env override', () => { | ||
const config = { | ||
base: { | ||
logLevel: Level.INFO, | ||
project: 'cool project', | ||
environment: 'production', | ||
}, | ||
Slack: { | ||
logLevel: Level.ERROR, | ||
slackToken: 'token', | ||
slackChannel: 'slack channel', | ||
}, | ||
Console: true, | ||
Fluentd: { | ||
collectorUrl: 'collector URL', | ||
}, | ||
}; | ||
|
||
const logger = new Logger(config); | ||
|
||
expect(logger.services).toHaveLength(3); | ||
logger.services.forEach((service) => { | ||
['Slack', 'Fluentd', 'Console'].forEach((serviceName) => { | ||
if (service instanceof services[serviceName]) { | ||
expect(service.config).toEqual( | ||
Object.assign({}, config.base, config[serviceName], { logLevel: Level.WARN }) | ||
); | ||
} | ||
}); | ||
}); | ||
}); | ||
}); |