Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit bbcdd5b

Browse files
committed
new test/constructor.js parameter tests
1 parent 8babda6 commit bbcdd5b

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

karma.conf.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ module.exports = function (config) {
4747
basePath: '',
4848
frameworks: ['mocha'],
4949
files: [
50-
'test/tests.js'
50+
'test/tests.js',
51+
'test/constructor.js'
5152
],
5253
exclude: [],
5354
preprocessors: {

test/constructor.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
'use strict'
2+
3+
const ipfsAPI = require('../src/index.js')
4+
const assert = require('assert')
5+
6+
describe('ipfsAPI constructor tests', () => {
7+
describe('parameter permuations', () => {
8+
const apiAddrs = require('./tmp-disposable-nodes-addrs.json')
9+
const apiAddr = apiAddrs.a.split('/')
10+
11+
function clientWorks (client, done) {
12+
client.id((err, res) => {
13+
if (err) throw err
14+
const id = res
15+
assert(id.ID)
16+
assert(id.PublicKey)
17+
done()
18+
})
19+
}
20+
21+
it('opts', (done) => {
22+
clientWorks(ipfsAPI({
23+
host: apiAddr[2],
24+
port: apiAddr[4],
25+
protocol: 'http'
26+
}), done)
27+
})
28+
29+
it('mutliaddr, opts', (done) => {
30+
clientWorks(ipfsAPI(
31+
apiAddrs.a,
32+
{protocol: 'http'}
33+
), done)
34+
})
35+
36+
it('host, port', (done) => {
37+
clientWorks(ipfsAPI(
38+
apiAddr[2],
39+
apiAddr[4]
40+
), done)
41+
})
42+
43+
it('host, port, opts', (done) => {
44+
clientWorks(ipfsAPI(
45+
apiAddr[2],
46+
apiAddr[4],
47+
{protocol: 'http'}
48+
), done)
49+
})
50+
})
51+
})

0 commit comments

Comments
 (0)