Skip to content

Commit

Permalink
Add unit test for crlf
Browse files Browse the repository at this point in the history
  • Loading branch information
tniessen committed Nov 2, 2017
1 parent 0e19daa commit d024331
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/crlf.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use strict'

var test = require('tap').test
var pino = require('../')
var Writable = require('stream').Writable

class LogWriteStream extends Writable {
constructor () {
super()
this.data = ''
}

write (data) {
this.data += data
}

toString () {
return this.data
}
}

test('pino uses LF by default', function (t) {
t.plan(1)
var stream = new LogWriteStream()
var logger = pino(stream)
logger.info('foo')
logger.error('bar')
t.ok(/foo[^\r\n]+\n[^\r\n]+bar[^\r\n]+\n/.test(stream.toString()));
t.end()
})

test('pino can log CRLF', function (t) {
t.plan(1)
var stream = new LogWriteStream()
var logger = pino({
crlf: true
}, stream)
logger.info('foo')
logger.error('bar')
t.ok(/foo[^\n]+\r\n[^\n]+bar[^\n]+\r\n/.test(stream.toString()));
t.end()
})

0 comments on commit d024331

Please sign in to comment.