Skip to content

Commit

Permalink
Adds Space.logging.Winston module integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
qejk committed May 2, 2016
1 parent ff902cf commit a3beb30
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Package.onTest(function(api) {

api.add_files([
'tests/unit/winston-adapter.unit.js',
'tests/integration/module.integration.js',
], 'server');

});
66 changes: 66 additions & 0 deletions tests/integration/module.integration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
describe("Space.logging.WinstonAdapter", function() {


beforeEach(function () {
this.winston = Npm.require('winston');
testApp = Space.Application.extend('Test.App', {
configuration: {},
requiredModules: ['Space.logging.Winston'],
});
this.app = new testApp();
this.app.start();
});

it('adds instance of Space.Logger.WinstonAdapter to instance of Space.Logger', function() {
const log = this.app.injector.get('log');
const adapter = log.adapter('winston');

expect(adapter).to.be.instanceof(Space.Logger.WinstonAdapter);
expect(adapter.lib()).to.be.instanceof(this.winston.Logger);
});

it('maps instance of Space.Logger.WinstonAdapter to Injector', function() {
expect(
this.app.injector.get('Space.Logger.WinstonAdapter')
).to.be.instanceof(Space.Logger.WinstonAdapter);
});

describe('configuration', function () {
describe('transports', function () {
it('uses default winston.transports.Console when transports are not configured', function() {
const logger = this.app.injector.get('log');
const adapter = logger.adapter('winston');

expect(adapter.hasTransport('console')).to.be.true;
});

it('overrides transports configuration', function() {
const options = {
colorize: false,
json: true,
level: 'error'
}
const testApp = Space.Application.extend('Test.App', {
configuration: {
log: {
enabled: true,
winston: {
transports: [new this.winston.transports.Console(options)]
}
}
},
requiredModules: ['Space.logging.Winston'],
});
const app = new testApp();
app.start();

const log = app.injector.get('log');
const adapter = log.adapter('winston');
const consoleTransport = adapter.transport('console');

expect(consoleTransport).to.include(options);
});
});
});

});

0 comments on commit a3beb30

Please sign in to comment.