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 297
/
Copy pathutil.spec.js
64 lines (51 loc) · 1.53 KB
/
util.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
/* 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 isNode = require('detect-node')
const ipfsClient = require('../src')
const f = require('./utils/factory')
describe('.util', () => {
if (!isNode) { return }
let ipfsd
let ipfs
before(function (done) {
this.timeout(20 * 1000) // slow CI
f.spawn({ initOptions: { bits: 1024, profile: 'test' } }, (err, _ipfsd) => {
expect(err).to.not.exist()
ipfsd = _ipfsd
ipfs = ipfsClient(_ipfsd.apiAddr)
done()
})
})
after(function (done) {
this.timeout(10 * 1000)
if (!ipfsd) return done()
ipfsd.stop(done)
})
describe('.getEndpointConfig', () => {
it('should return the endpoint configuration', function () {
const endpoint = ipfs.util.getEndpointConfig()
expect(endpoint.host).to.equal('127.0.0.1')
expect(endpoint.protocol).to.equal('http')
expect(endpoint['api-path']).to.equal('/api/v0/')
// changes per test run so we just assert it exists.
expect(endpoint).to.have.property('port')
})
})
describe('.crypto', () => {
it('should contain the crypto primitives object', function () {
const cripto = ipfs.util.crypto
expect(cripto).to.exist()
})
})
describe('.isIPFS', () => {
it('should contain the isIPFS utilities object', function () {
const isIPFS = ipfs.util.isIPFS
expect(isIPFS).to.exist()
})
})
})