This repository has been archived by the owner on Aug 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
50 lines (42 loc) · 1.38 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import test from 'ava'
import devnull from 'dev-null'
import ConsoleLogFmt from './index'
const stdout = devnull()
const stderr = devnull()
test('simple info message', t => {
const { log } = new ConsoleLogFmt({ stdout, stderr })
t.is(log('message'), 'level=info msg=message')
})
test('simple warn message', t => {
const { warn } = new ConsoleLogFmt({ stdout, stderr })
t.is(warn('message'), 'level=warn msg=message')
})
test('simple error message', t => {
const { error } = new ConsoleLogFmt({ stdout, stderr })
t.is(error('message'), 'level=error msg=message')
})
test('log of multiple string params', t => {
const { log } = new ConsoleLogFmt({ stdout, stderr })
t.is(
log('message', 'of', 'a lot of', 'words'),
'level=info msg="message of a lot of words"'
)
})
test('log of nested object as plain', t => {
const { log } = new ConsoleLogFmt({ stdout, stderr })
t.is(log({ father: { to: 'son' } }), 'level=info father_to=son')
})
test('log of multiple nested object as plain', t => {
const { log } = new ConsoleLogFmt({ stdout, stderr })
t.is(
log({ father: { to: 'son', and: 'daugher' } }),
'level=info father_to=son father_and=daugher'
)
})
test('log of multi-level nested objects as plain', t => {
const { log } = new ConsoleLogFmt({ stdout, stderr })
t.is(
log({ grand: { father: { to: 'son' } } }),
'level=info grand_father_to=son'
)
})