-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge refs/heads/master into version_4.3.1
- Loading branch information
Showing
3 changed files
with
24 additions
and
8 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,21 @@ | ||
const chai = require('chai') | ||
const assert = chai.assert | ||
const path = require('path') | ||
const fs = require('fs').promises | ||
const logger = require('../server/utils/logging.js') | ||
|
||
const convertOneDigitToTwo = (number) => { | ||
return ('0' + (number)).slice(-2) | ||
} | ||
|
||
describe('logging', () => { | ||
it('should log currect datetime', async () => { | ||
logger.log2('debug', 'hello this is a dummy log testing') | ||
const passportLogFilePath = path.join(__dirname, '../server/utils/logs/passport.log') | ||
const logText = await fs.readFile(passportLogFilePath, 'binary') | ||
const newDate = new Date() | ||
// YYYY-MM-DD HH | ||
const currentDateTimeTillHour = `${newDate.getFullYear()}-${convertOneDigitToTwo(newDate.getMonth() + 1)}-${convertOneDigitToTwo(newDate.getDate())} ${convertOneDigitToTwo(newDate.getHours())}` | ||
assert(logText.includes(currentDateTimeTillHour), 'hello this is a dummy log testing') | ||
}) | ||
}) |
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