Skip to content

Commit c76d957

Browse files
committed
test: add more utils tests
Add tests for utils.connectionLogLocation and utils.channelLogLocation
1 parent 826cdfa commit c76d957

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

test/utils.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,60 @@
33
const test = require('tap').test
44
const utils = require('../lib/utils')
55

6+
test('connectionLogLocation', (t) => {
7+
let conn = {
8+
settings: new Map([
9+
['transcripts.enabled', true]
10+
, ['transcripts.location', '/tmp']
11+
])
12+
, name: 'Freenode'
13+
}
14+
15+
let out = utils.connectionLogLocation(conn)
16+
t.equal(out, '/tmp/Connections/Freenode/Console', 'result is correct')
17+
18+
conn.settings.delete('transcripts.location')
19+
out = utils.connectionLogLocation(conn)
20+
t.equal(out, null, 'result is correct')
21+
22+
conn.settings.set('transcripts.enabled', false)
23+
out = utils.connectionLogLocation(conn)
24+
t.equal(out, null, 'result is correct')
25+
26+
t.end()
27+
})
28+
29+
test('channelLogLocation', (t) => {
30+
const base = '/tmp/Connections/Freenode'
31+
let conn = {
32+
settings: new Map([
33+
['transcripts.enabled', true]
34+
, ['transcripts.location', '/tmp']
35+
])
36+
, name: 'Freenode'
37+
}
38+
39+
let chan = {
40+
getConnection: () => {
41+
return conn
42+
}
43+
, type: 'channel'
44+
, name: '#node.js'
45+
}
46+
47+
let out = utils.channelLogLocation(chan)
48+
t.equal(out, `${base}/Channels/#node.js`, 'result is correct')
49+
chan.type = 'private'
50+
51+
out = utils.channelLogLocation(chan)
52+
t.equal(out, `${base}/Messages/#node.js`, 'result is correct')
53+
54+
conn.settings.set('transcripts.enabled', false)
55+
out = utils.channelLogLocation(chan)
56+
t.equal(out, null, 'result is correct')
57+
t.end()
58+
})
59+
660
test('date', (t) => {
761
const d = new Date()
862
d.setSeconds(2)

0 commit comments

Comments
 (0)