Skip to content

Commit

Permalink
feat: making tests run in browser and node
Browse files Browse the repository at this point in the history
  • Loading branch information
dryajov committed Dec 1, 2017
1 parent 70db1b2 commit b6ad854
Show file tree
Hide file tree
Showing 14 changed files with 835 additions and 108 deletions.
15 changes: 12 additions & 3 deletions .aegir.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
'use strict'

const tasks = require('./src/remote-factory/tasks')
const server = require('./src/remote/server')

module.exports = {
karma: {
files: [{
pattern: 'test/fixtures/**/*',
watched: false,
served: true,
included: false
}],
singleRun: true
},
hooks: {
browser: {
pre: tasks.start,
post: tasks.stop
pre: server.start,
post: server.stop
}
}
}
21 changes: 20 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@
"scripts": {
"lint": "aegir lint",
"coverage": "aegir coverage",
"test": "aegir test -t node --timeout 50000",
"test": "aegir test -t node -t browser --no-cors --timeout 50000",
"test:node": "aegir test -t node --timeout 50000",
"test:browser": "aegir test -t browser --no-cors --timeout 50000",
"docs": "aegir docs",
"release": "aegir release -t node",
"release-minor": "aegir release --type minor -t node",
"release-major": "aegir release --type major -t node",
"coverage-publish": "aegir coverage -u"
},
"browser": {
"./src/daemon.js": false,
"glob": false,
"fs": false,
"stream": "readable-stream",
"http": "stream-http"
},
"engines": {
"node": ">=6.0.0",
"npm": ">=3.0.0"
Expand Down Expand Up @@ -51,16 +60,26 @@
"license": "MIT",
"dependencies": {
"async": "^2.6.0",
"debug": "^3.1.0",
"detect-node": "^2.0.3",
"eslint-config-standard-jsx": "^4.0.2",
"go-ipfs-dep": "0.4.13",
"guid": "0.0.12",
"hapi": "^16.6.2",
"http-browserify": "^1.7.0",
"ipfs-api": "^17.1.3",
"lodash.clonewith": "^4.5.0",
"lodash.get": "^4.4.2",
"lodash.mapvalues": "^4.6.0",
"lodash.merge": "^4.6.0",
"multiaddr": "^3.0.1",
"once": "^1.4.0",
"qs": "^6.5.1",
"readable-stream": "^2.3.3",
"request": "^2.83.0",
"rimraf": "^2.6.2",
"shutdown": "^0.3.0",
"stream-http": "^2.7.2",
"subcomandante": "^1.0.5",
"truthy": "0.0.1"
},
Expand Down
14 changes: 14 additions & 0 deletions src/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class Node {
this.env = this.path ? Object.assign({}, process.env, { IPFS_PATH: this.path }) : process.env
this._apiAddr = null
this._gatewayAddr = null
this._started = false

if (this.opts.env) {
Object.assign(this.env, this.opts.env)
Expand All @@ -133,6 +134,15 @@ class Node {
return this._gatewayAddr
}

/**
* Is the node started
*
* @return {boolean}
*/
get started () {
return this._started
}

_run (args, opts, callback) {
return exec(this.exec, args, opts, callback)
}
Expand Down Expand Up @@ -262,6 +272,7 @@ class Node {

if (output.match(/(?:daemon is running|Daemon is ready)/)) {
// we're good
this._started = true
return callback(null, this.api)
}
}
Expand Down Expand Up @@ -335,6 +346,9 @@ class Node {
callback = key
key = 'show'
}
if (!key) {
key = 'show'
}

async.waterfall([
(cb) => this._run(
Expand Down
8 changes: 8 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ const waterfall = require('async/waterfall')
const Node = require('./daemon')

const defaultOptions = {
config: {
'API.HTTPHeaders.Access-Control-Allow-Origin': ['*'],
'API.HTTPHeaders.Access-Control-Allow-Methods': [
'PUT',
'POST',
'GET'
]
},
disposable: true,
start: true,
init: true
Expand Down
Loading

0 comments on commit b6ad854

Please sign in to comment.