diff --git a/.babelrc b/.babelrc new file mode 100644 index 000000000..27bed82ed --- /dev/null +++ b/.babelrc @@ -0,0 +1,12 @@ +{ + "env": { + "test": { + "plugins": [ "istanbul" ] + } + }, + "presets": [ + "env", + "stage-2", + "react" + ] +} \ No newline at end of file diff --git a/.compilerc b/.compilerc index a7f057371..de2381013 100644 --- a/.compilerc +++ b/.compilerc @@ -14,9 +14,6 @@ "stage-2", "react" ], - "plugins": [ - "transform-async-to-generator" - ], "sourceMaps": "inline" } }, @@ -34,9 +31,6 @@ "stage-2", "react" ], - "plugins": [ - "transform-async-to-generator" - ], "sourceMaps": "none" } } diff --git a/.gitignore b/.gitignore index 420b6d207..d28fd1ecf 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,8 @@ out *.lock package-lock.json dist -*.zip \ No newline at end of file +*.zip +coverage +.nyc_output +coverage.lcov +.cache \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 3dfac9928..16be65197 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,4 +5,5 @@ node_js: script: - npm run lint - + - npm run test + - npm run coverage diff --git a/README.md b/README.md index 3027aa28f..9efb72a29 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,9 @@
diff --git a/package.json b/package.json index 979456bc8..227612f60 100644 --- a/package.json +++ b/package.json @@ -7,17 +7,18 @@ "main": "src/index.js", "dependencies": { "auto-launch": "^5.0.5", + "bl": "^1.2.1", "debug": "^3.1.0", "electron-compile": "^6.4.2", "electron-menubar": "^1.0.1", "electron-squirrel-startup": "^1.0.0", + "file-extension": "^4.0.1", "go-ipfs-dep": "^0.4.13", + "ipfs-stats": "^1.2.1", "ipfsd-ctl": "^0.27.0", - "file-extension": "^4.0.1", - "ipfs-stats": "^1.0.4", + "is-ipfs": "^0.3.2", "moment": "^2.20.1", "multiaddr": "^3.0.2", - "is-ipfs": "^0.3.2", "normalize.css": "^7.0.0", "pretty-bytes": "^4.0.2", "prop-types": "^15.6.0", @@ -28,26 +29,51 @@ }, "devDependencies": { "babel-eslint": "^8.2.1", - "babel-plugin-transform-async-to-generator": "^6.24.1", + "babel-plugin-istanbul": "^4.1.5", "babel-preset-env": "^1.6.1", "babel-preset-react": "^6.24.1", "babel-preset-stage-2": "^6.24.1", + "chai": "^4.1.2", + "codecov": "^3.0.0", + "cross-env": "^5.1.3", "electron-forge": "^4.2.0", - "electron-prebuilt-compile": "1.8.1", + "electron-prebuilt-compile": "1.8.2-beta.3", + "enzyme": "^3.3.0", + "enzyme-adapter-react-16": "^1.1.1", "eslint": "^4", "eslint-config-aegir": "^1.0.1", "eslint-config-standard-react": "^5.0.0", "eslint-plugin-import": "^2", "eslint-plugin-jsx-a11y": "^6", "eslint-plugin-react": "^7", - "pre-commit": "^1.2.2" + "expect": "^22.1.0", + "istanbul": "^0.4.5", + "jsdom": "^11.6.1", + "mocha": "^5.0.0", + "nyc": "^11.4.1", + "pre-commit": "^1.2.2", + "sinon": "^4.2.2", + "spectron": "^3.8.0" }, "scripts": { "start": "electron-forge start", "package": "electron-forge package", "make": "electron-forge make", "publish": "electron-forge publish", - "lint": "eslint ." + "lint": "eslint .", + "test": "cross-env NODE_ENV=test nyc --all mocha --require babel-core/register --require ./test/setup.js --recursive", + "coverage": "(nyc report --reporter=text-lcov > coverage.lcov) && codecov" + }, + "nyc": { + "include": [ + "src/**/*.js*" + ], + "reporter": [ + "lcov", + "text" + ], + "sourceMap": false, + "instrument": false }, "config": { "forge": { diff --git a/src/components/Block.js b/src/components/Block.js new file mode 100644 index 000000000..3f7495957 --- /dev/null +++ b/src/components/Block.js @@ -0,0 +1,45 @@ +import React from 'react' +import PropTypes from 'prop-types' + +/** + * It's a Block. + * + * @param {Object} props + * + * @prop {Any} wrapped + * @prop {Any} unwrapped + * @prop {Function} [onClick] + * + * @return {ReactElement} + */ +export default function Block (props) { + let className = 'block' + if (props.className !== '') { + className += ' ' + props.className + } + + if (props.onClick !== null) { + className += ' clickable' + } + + return ( +{props.title}
-{props.info}
-{props.title}
+{props.info}
+{this.props.name}
+ { this.state.deleting && +Are you sure? This is permanent.
+ } + { !this.state.deleting && +{prettyBytes(this.props.size)} | {this.props.hash}
+ } +{props.title}
{info}{props.name}
-{moment(props.date).fromNow()}
-- You do not have any files yet. Add your first one by dropping - it here or clicking on one of the buttons on the bottom right side. -
- ) - } - - return connectDropTarget( -{prettyBytes(props.repo.RepoSize)}
-Sharing {props.repo.NumObjects} objects
-+ You do not have any files yet. Add your first one by dropping + it here or clicking on one of the buttons on the bottom right side. +
+ ) + } + + return connectDropTarget( +{prettyBytes(props.repo.repoSize)}
+Sharing {props.repo.numObjects} objects
+It seems your daemon is not running yet. You can either start the daemon or quit the application.
+ +