Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ matrix:
before_install:
- npm install -g npm

script:
before_script:
- npm run lint
- npm run test

script:
- npm run test:node
- npm run test:browser
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why separate?

- npm run coverage

before_script:
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"http": "stream-http"
},
"scripts": {
"test": "gulp test",
"test:node": "gulp test:node",
"test:browser": "gulp test:browser",
"test": "node --max_old_space_size=4096 node_modules/.bin/gulp test",
"test:node": "node --max_old_space_size=4096 node_modules/.bin/gulp test:node",
"test:browser": "node --max_old_space_size=4096 node_modules/.bin/gulp test:browser",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this? I believe we fixed the webpack hungryness when we migrated all the tests to use factory only

"lint": "aegir-lint",
"build": "gulp build",
"release": "gulp release",
Expand Down Expand Up @@ -66,7 +66,7 @@
"gulp": "^3.9.1",
"hapi": "^16.1.0",
"interface-ipfs-core": "~0.24.1",
"ipfsd-ctl": "~0.18.2",
"ipfsd-ctl": "~0.19.0",
"pre-commit": "^1.2.2",
"socket.io": "^1.7.2",
"socket.io-client": "^1.7.2",
Expand Down
24 changes: 14 additions & 10 deletions test/constructor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,30 @@ function clientWorks (client, done) {

describe('ipfs-api constructor tests', () => {
describe('parameter permuations', () => {
let apiAddr
let fc
let apiAddr
let host
let port

before(function (done) {
this.timeout(20 * 1000) // slow CI
fc = new FactoryClient()
fc.spawnNode((err, node) => {
expect(err).to.not.exist
expect(node.apiAddr).to.exist
apiAddr = node.apiAddr
host = apiAddr.nodeAddress().address
port = apiAddr.nodeAddress().port
done()
})
})

after((done) => fc.dismantle(done))

it('opts', (done) => {
const splitted = apiAddr.split('/')
clientWorks(ipfsAPI({
host: splitted[2],
port: splitted[4],
host: host,
port: port,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

protocol: 'http'
}), done)
})
Expand All @@ -46,16 +50,16 @@ describe('ipfs-api constructor tests', () => {
clientWorks(ipfsAPI(apiAddr, { protocol: 'http' }), done)
})

it('host, port', (done) => {
const splitted = apiAddr.split('/')
it('multiaddr (string), opts', (done) => {
clientWorks(ipfsAPI(apiAddr.toString(), { protocol: 'http' }), done)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to specify the protocol now ?

})

clientWorks(ipfsAPI(splitted[2], splitted[4]), done)
it('host, port', (done) => {
clientWorks(ipfsAPI(host, port), done)
})

it('host, port, opts', (done) => {
const splitted = apiAddr.split('/')

clientWorks(ipfsAPI(splitted[2], splitted[4], { protocol: 'http' }), done)
clientWorks(ipfsAPI(host, port, { protocol: 'http' }), done)
})
})
})
6 changes: 4 additions & 2 deletions test/ipfs-factory/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const io = require('socket.io-client')
const ipfsAPI = require('../../src')
const Multiaddr = require('multiaddr')

module.exports = Factory

Expand Down Expand Up @@ -40,8 +41,9 @@ function Factory () {

function spawnNode () {
ioC.once('fc-node', (apiAddr) => {
const ipfs = ipfsAPI(apiAddr)
ipfs.apiAddr = apiAddr
const addr = new Multiaddr(apiAddr)
const ipfs = ipfsAPI(addr)
ipfs.apiAddr = addr
callback(null, ipfs)
})
ioC.emit('fs-spawn-node', repoPath, config)
Expand Down
2 changes: 1 addition & 1 deletion test/ipfs-factory/server-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = (http) => {
if (err) {
throw err
}
this.emit('fc-node', apiAddr)
this.emit('fc-node', apiAddr.toString())
})
}

Expand Down
4 changes: 2 additions & 2 deletions test/name.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('.name', () => {
expect(err).to.not.exist
expect(res).to.exist
expect(res).to.be.eql({
Path: '/ipfs/' + name.Value
Path: name.Value
})
done()
})
Expand All @@ -99,7 +99,7 @@ describe('.name', () => {
.then((res) => {
expect(res).to.exist
expect(res).to.be.eql({
Path: '/ipfs/' + name.Value
Path: name.Value
})
})
})
Expand Down