Select Git revision
index.test.js
-
Sigmund, Dominik authoredSigmund, Dominik authored
index.test.js 9.30 KiB
/* global it, describe, beforeEach, afterEach */
const assert = require('assert')
const os = require('os')
const path = require('path')
const fs = require('fs')
const LOG = require('./index')
const hostname = os.hostname()
function getDate () {
var tzoffset = (new Date()).getTimezoneOffset() * 60000 // offset in milliseconds
var localISOTime = (new Date(Date.now() - tzoffset)).toISOString().slice(0, -1)
return localISOTime.split('.')[0].trim()
}
const manualhostname = 'testhost'
const name = 'testapp'
let file = 'testfile'
const filePath = '/tmp'
let orginialFile
let log
let line
let testline
describe('@br/Log', () => {
describe(': No Options', () => {
beforeEach(() => {
console.log('create Object')
log = new LOG()
})
afterEach(() => {
console.log('destroy Object')
log = undefined
})
describe(': Info', () => {
it('should output empty line - standard log-level without options is warn', () => {
line = log.info('testline')
assert.equal(line, '')
})
})
describe(': Notice', () => {
it('should output empty line - standard log-level without options is warn', () => {
line = log.notice('testline')
assert.equal(line, '')
})
})
describe(': Warn', () => {
it('should output the given Line', () => {
testline = getDate() + '\t' + hostname + '\t@br/log\tWARN\ttestline'
line = log.warn('testline')
assert.equal(line, testline)
})
})
describe(': Error', () => {
it('should output the given Line', () => {
testline = getDate() + '\t' + hostname + '\t@br/log\tERROR\ttestline'
line = log.error('testline')
assert.equal(line, testline)
})
})
describe(': Fatal', () => {
it('should output the given Line', () => {
testline = getDate() + '\t' + hostname + '\t@br/log\tFATAL\ttestline'
line = log.fatal('testline')
assert.equal(line, testline)
})
})
describe(': Debug', () => {
it('should output the given Line', () => {
line = log.debug('testline')
assert.equal(line, '')
})
})