Skip to content

Commit 6b04506

Browse files
committed
feat: clean up and cosolidate tests
1 parent 0f0787a commit 6b04506

File tree

6 files changed

+500
-474
lines changed

6 files changed

+500
-474
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"lint": "aegir lint",
88
"coverage": "aegir coverage",
9-
"test": "aegir test --target node",
9+
"test": "aegir test -t node --timeout 50000",
1010
"docs": "aegir docs",
1111
"release": "aegir release -t node",
1212
"release-minor": "aegir release --type minor -t node",

src/daemon.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ const path = require('path')
1010
const join = path.join
1111
const once = require('once')
1212
const os = require('os')
13+
const truthy = require('truthy')
14+
1315
const isWindows = os.platform() === 'win32'
1416

1517
const exec = require('./exec')
@@ -91,7 +93,7 @@ class Node {
9193
*/
9294
constructor (path, opts, disposable) {
9395
const rootPath = process.env.testpath ? process.env.testpath : __dirname
94-
const isJS = process.env.IPFS_JS && process.env.IPFS_JS === 'true' // TODO: handle proper truthy/falsy
96+
const isJS = truthy(process.env.IPFS_JS)
9597

9698
this.opts = opts || { isJs: isJS || false }
9799
process.env.IPFS_JS = this.opts.isJs

test/daemon.spec.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* eslint-env mocha */
2+
'use strict'
3+
4+
const daemon = require('./spawning-daemons.js')
5+
6+
describe('ipfsd-ctl', () => {
7+
describe('Go daemon', () => {
8+
daemon(false)()
9+
})
10+
11+
describe('Js daemon', () => {
12+
daemon(true)()
13+
})
14+
})

test/npm-installs.spec.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ describe('ipfs executable path', () => {
1717
const tmp = os.tmpdir()
1818
const appName = isWindows ? 'ipfs.exe' : 'ipfs'
1919

20+
const oldPath = process.env.testpath
21+
before(() => { process.env.testpath = path.join(tmp, 'ipfsd-ctl-test/node_modules/ipfsd-ctl/lib') }) // fake __dirname
22+
after(() => { process.env.testpath = oldPath })
23+
2024
it('has the correct path when installed with npm3', (done) => {
21-
process.env.testpath = path.join(tmp, 'ipfsd-ctl-test/node_modules/ipfsd-ctl/lib') // fake __dirname
2225
let npm3Path = path.join(tmp, 'ipfsd-ctl-test/node_modules/go-ipfs-dep/go-ipfs')
2326

2427
mkdirp(npm3Path, (err) => {
@@ -36,8 +39,6 @@ describe('ipfs executable path', () => {
3639
})
3740

3841
it('has the correct path when installed with npm2', (done) => {
39-
process.env.testpath = path.join(tmp, 'ipfsd-ctl-test/node_modules/ipfsd-ctl/lib') // fake __dirname
40-
4142
let npm2Path = path.join(tmp, 'ipfsd-ctl-test/node_modules/ipfsd-ctl/node_modules/go-ipfs-dep/go-ipfs')
4243

4344
mkdirp(npm2Path, (err) => {

0 commit comments

Comments
 (0)