|
3 | 3 | const test = require('tap').test |
4 | 4 | const utils = require('../lib/utils') |
5 | 5 |
|
| 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 | + |
6 | 60 | test('date', (t) => { |
7 | 61 | const d = new Date() |
8 | 62 | d.setSeconds(2) |
|
0 commit comments