This repository was archived by the owner on Mar 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 298
/
Copy pathlog.spec.js
73 lines (58 loc) · 1.48 KB
/
log.spec.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* eslint-env mocha */
/* eslint max-nested-callbacks: ["error", 8] */
'use strict'
const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const IPFSApi = require('../src')
const f = require('./utils/factory')
describe('.log', function () {
this.timeout(100 * 1000)
let ipfsd
let ipfs
before((done) => {
f.spawn({ initOptions: { bits: 1024 } }, (err, _ipfsd) => {
expect(err).to.not.exist()
ipfsd = _ipfsd
ipfs = IPFSApi(_ipfsd.apiAddr)
done()
})
})
after((done) => {
if (!ipfsd) return done()
ipfsd.stop(done)
})
it('.log.tail', (done) => {
let i = setInterval(() => {
ipfs.add(Buffer.from('just adding some data to generate logs'))
}, 1000)
const req = ipfs.log.tail((err, res) => {
expect(err).to.not.exist()
expect(req).to.exist()
res.once('data', (obj) => {
clearInterval(i)
expect(obj).to.be.an('object')
done()
})
})
})
it('.log.ls', (done) => {
ipfs.log.ls((err, res) => {
expect(err).to.not.exist()
expect(res).to.exist()
expect(res).to.be.an('array')
done()
})
})
it('.log.level', (done) => {
ipfs.log.level('all', 'error', (err, res) => {
expect(err).to.not.exist()
expect(res).to.exist()
expect(res).to.be.an('object')
expect(res).to.not.have.property('Error')
expect(res).to.have.property('Message')
done()
})
})
})