-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcustom-logger.test.ts
52 lines (46 loc) · 1.01 KB
/
custom-logger.test.ts
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
51
52
import test from 'ava'
import { start } from '../src'
import { Adapter, AdapterEndpoint } from '../src/adapter'
import { LoggerFactory } from '../src/util/logger'
import { NopTransport } from '../src/util/testing-utils'
test('custom logger instance is properly injected', async (t) => {
let timesCalled = 0
const loggerFactory: LoggerFactory = {
child: () => {
return {
fatal: () => {
timesCalled++
},
error: () => {
timesCalled++
},
warn: () => {
timesCalled++
},
info: () => {
timesCalled++
},
debug: () => {
timesCalled++
},
trace: () => {
timesCalled++
},
}
},
}
const adapter = new Adapter({
name: 'TEST',
endpoints: [
new AdapterEndpoint({
name: 'test',
transport: new NopTransport(),
}),
],
})
t.is(timesCalled, 0)
await start(adapter, {
loggerFactory,
})
t.true(timesCalled > 0)
})