forked from feedhenry/fh-mbaas-api
-
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.
- Loading branch information
Showing
8 changed files
with
120 additions
and
19 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,81 @@ | ||
var sinon = require('sinon'); | ||
var consolelogger = require('../lib/consolelogger'); | ||
var expect = require('chai').expect; | ||
require('mocha-sinon'); | ||
|
||
var logger = new consolelogger.ConsoleLogger(); | ||
|
||
|
||
function getTS() { | ||
var d = new Date(); | ||
var day = d.getDate() < 10 ? "0" + d.getDate() : d.getDate(); | ||
var mon = d.getMonth() < 10 ? "0" + d.getMonth() : d.getMonth(); | ||
var hour = d.getHours() < 10 ? "0" + d.getHours() : d.getHours(); | ||
var min = d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes(); | ||
var sec = d.getSeconds() < 10 ? "0" + d.getSeconds() : d.getSeconds(); | ||
|
||
return d.getFullYear() + "-" + mon + "-" + day + | ||
" " + hour + ":" + min + ":" + sec; | ||
} | ||
|
||
|
||
module.exports = { | ||
beforeEach: function() { | ||
var log = console.log; | ||
this.sinon.stub(console, 'log', function() { | ||
return log.apply(log, arguments); | ||
}); | ||
}, | ||
|
||
'test error log level 0': function(done) { | ||
logger.setLogLevel(consolelogger.LEVEL.ERROR); | ||
logger.error('error'); | ||
expect(console.log.calledWith(getTS() + ' ERROR error')).to.be.true; | ||
logger.warning('warning'); | ||
expect(console.log.calledWith(getTS() + ' WARN warning')).to.be.false; | ||
logger.info('info'); | ||
expect(console.log.calledWith(getTS() + ' INFO info')).to.be.false; | ||
logger.debug('debug'); | ||
expect(console.log.calledWith(getTS() + ' DEBUG debug')).to.be.false; | ||
done(); | ||
}, | ||
|
||
'test error log level 1': function(done) { | ||
logger.setLogLevel(consolelogger.LEVEL.WARN); | ||
logger.error('error'); | ||
expect(console.log.calledWith(getTS() + ' ERROR error')).to.be.true; | ||
logger.warning('warning'); | ||
expect(console.log.calledWith(getTS() + ' WARN warning')).to.be.true; | ||
logger.info('info'); | ||
expect(console.log.calledWith(getTS() + ' INFO info')).to.be.false; | ||
logger.debug('debug'); | ||
expect(console.log.calledWith(getTS() + ' DEBUG debug')).to.be.false; | ||
done(); | ||
}, | ||
|
||
'test error log level 2': function(done) { | ||
logger.setLogLevel(consolelogger.LEVEL.INFO); | ||
logger.error('error'); | ||
expect(console.log.calledWith(getTS() + ' ERROR error')).to.be.true; | ||
logger.warning('warning'); | ||
expect(console.log.calledWith(getTS() + ' WARN warning')).to.be.true; | ||
logger.info('info'); | ||
expect(console.log.calledWith(getTS() + ' INFO info')).to.be.true; | ||
logger.debug('debug'); | ||
expect(console.log.calledWith(getTS() + ' DEBUG warning')).to.be.false; | ||
done(); | ||
}, | ||
|
||
'test error log level 3': function(done) { | ||
logger.setLogLevel(consolelogger.LEVEL.DEBUG); | ||
logger.error('error'); | ||
expect(console.log.calledWith(getTS() + ' ERROR error')).to.be.true; | ||
logger.warning('warning'); | ||
expect(console.log.calledWith(getTS() + ' WARN warning')).to.be.true; | ||
logger.info('info'); | ||
expect(console.log.calledWith(getTS() + ' INFO info')).to.be.true; | ||
logger.debug('debug'); | ||
expect(console.log.calledWith(getTS() + ' DEBUG debug')).to.be.true; | ||
done(); | ||
} | ||
}; |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
REM use the command "npm run testwindows" to run this test script, that will use the correct path for turbo.cmd | ||
REM if updating the list of tests, please also ensure that it's reflected in the Gruntfile.js list also | ||
REM | ||
turbo.cmd --setUp ./test/setup.js --tearDown ./test/setup.js ./test/test_fhutils.js && turbo.cmd --setUp ./test/setup.js --tearDown ./test/setup.js ./test/test_fhact.js && turbo.cmd --setUp ./test/setup.js --tearDown ./test/setup.js ./test/test_fhfeed.js && turbo.cmd --setUp ./test/setup.js --tearDown ./test/setup.js ./test/test_fhforms.js && turbo.cmd --setUp ./test/setup.js --tearDown ./test/setup.js ./test/test_fhsec.js && turbo.cmd --setUp ./test/setup.js --tearDown ./test/setup.js ./test/test_fhsession.js && turbo.cmd --setUp ./test/setup.js --tearDown ./test/setup.js ./test/test_fhstat.js && turbo.cmd --setUp ./test/setup.js --tearDown ./test/setup.js ./test/test_cache.js && turbo.cmd --setUp ./test/setup.js --tearDown ./test/setup.js ./test/test_redis.js && turbo.cmd --setUp ./test/setup.js --tearDown ./test/setup.js ./test/test_sync.js && turbo.cmd --setUp ./test/setup.js --tearDown ./test/setup.js ./test/test_fhauth.js | ||
turbo.cmd --setUp ./test/setup.js --tearDown ./test/setup.js ./test/test_fhutils.js && turbo.cmd --setUp ./test/setup.js --tearDown ./test/setup.js ./test/test_fhact.js && turbo.cmd --setUp ./test/setup.js --tearDown ./test/setup.js ./test/test_fhfeed.js && turbo.cmd --setUp ./test/setup.js --tearDown ./test/setup.js ./test/test_fhforms.js && turbo.cmd --setUp ./test/setup.js --tearDown ./test/setup.js ./test/test_fhsec.js && turbo.cmd --setUp ./test/setup.js --tearDown ./test/setup.js ./test/test_fhsession.js && turbo.cmd --setUp ./test/setup.js --tearDown ./test/setup.js ./test/test_fhstat.js && turbo.cmd --setUp ./test/setup.js --tearDown ./test/setup.js ./test/test_cache.js && turbo.cmd --setUp ./test/setup.js --tearDown ./test/setup.js ./test/test_redis.js && turbo.cmd --setUp ./test/setup.js --tearDown ./test/setup.js ./test/test_sync.js && turbo.cmd --setUp ./test/setup.js --tearDown ./test/setup.js ./test/test_fhauth.js && turbo.cmd --setUp ./test/setup.js --tearDown ./test/setup.js ./test/test_log.js |