-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Space.logging.Winston module integration test
- Loading branch information
Showing
2 changed files
with
67 additions
and
0 deletions.
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,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); | ||
}); | ||
}); | ||
}); | ||
|
||
}); |