From 5bb03c32f24afb491112fdb663678b90280a17aa Mon Sep 17 00:00:00 2001 From: Lionel Breduillieard Date: Wed, 26 Nov 2014 20:44:50 +0100 Subject: [PATCH 1/4] Remove buggy gulp-webserver and replace by a hand made one --- gulpfile.js | 30 +++++++++++++++++++++++++----- package.json | 6 +++++- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index c95ce31..791c585 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -7,7 +7,6 @@ var browserify = require('browserify'); var watchify = require('watchify'); var source = require('vinyl-source-stream'); var uglify = require('gulp-uglify'); -var webserver = require("gulp-webserver"); var deploy = require("gulp-gh-pages"); var opt = { @@ -16,7 +15,7 @@ var opt = { server: { host: "localhost", port: 4000, - livereload: true, + livereload: 35729, open:true }, @@ -102,9 +101,25 @@ gulp.task("js:vendors", function() { /** * Server task */ +// gulp.task("server", function() { +// return gulp.src(opt.outputFolder) +// .pipe(webserver(opt.server)); +// }); +// +var connect = require('connect'); +var livereload = require('connect-livereload'); +var staticFile = require('serve-static'); +var lrServer = require('tiny-lr')(); + gulp.task("server", function() { - return gulp.src(opt.outputFolder) - .pipe(webserver(opt.server)); + + lrServer + .listen(opt.server.livereload); + + connect() + .use(livereload({ port: opt.server.livereload })) + .use(staticFile(opt.outputFolder)) + .listen(4000); }); /** @@ -147,6 +162,9 @@ gulp.task("watch", ["assets","js:vendors", "watchify"], function() { gulp.watch(opt.cssAssets, ["assets:css"]); gulp.watch(opt.fontAssets, ["assets:fonts"]); gulp.watch(opt.htmlAssets, ["assets:html"]); + gulp.watch(opt.outputFolder+"/**/*", function(file){ + lrServer.changed({body : {files : [file.path]}}); + }); }); gulp.task("dist", ["assets", "js"], function() { @@ -163,4 +181,6 @@ gulp.task("deploy", ["dist"], function() { .pipe(deploy("git@github.com:n1k0/kept.git")); }); -gulp.task("default", ["server", "watch"]); +gulp.task("default", ["server", "watch"], function(){ + require('opn')("http://"+opt.server.host+":"+opt.server.port); +}); diff --git a/package.json b/package.json index a21e88e..cbb5413 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,11 @@ "vinyl-source-stream": "^0.1.*", "watchify": "^1.0.6", "browserify": "^6.0.2", - "gulp-webserver": "^0.8.3" + "connect": "^3.3.3", + "connect-livereload": "^0.5.2", + "serve-static": "^1.7.1", + "tiny-lr": "^0.1.4", + "opn": "^1.0.0" }, "devDependencies": { "jest-cli": "latest", From 9e87dc00f9fc3810419b8e07aabd78fa1810486d Mon Sep 17 00:00:00 2001 From: Lionel Breduillieard Date: Mon, 1 Dec 2014 15:48:06 +0100 Subject: [PATCH 2/4] update react version 0.14 rename js file to jsx remove jsx pragma update project dependencies update to react v0.14 api --- .eslintrc | 6 +++ gulpfile.js | 44 +++++++++++-------- package.json | 28 +++++++----- src/css/kept.css | 6 ++- .../{DefaultContent.js => DefaultContent.jsx} | 2 - .../{GlyphiconLink.js => GlyphiconLink.jsx} | 7 ++- src/js/components/{KeptApp.js => KeptApp.jsx} | 3 -- .../{KeptColumns.js => KeptColumns.jsx} | 4 +- .../{KeptEntry.js => KeptEntry.jsx} | 23 +++++----- .../{KeptItems.js => KeptItems.jsx} | 4 +- .../{KeptMenuBar.js => KeptMenuBar.jsx} | 2 - ...ontent-test.js => DefaultContent-test.jsx} | 2 - .../{KeptApp-test.js => KeptApp-test.jsx} | 2 - ...ptColumns-test.js => KeptColumns-test.jsx} | 2 - .../{KeptEntry-test.js => KeptEntry-test.jsx} | 2 - .../{KeptItems-test.js => KeptItems-test.jsx} | 2 - .../text/{KeptText.js => KeptText.jsx} | 2 - .../{KeptTextForm.js => KeptTextForm.jsx} | 10 ++--- .../{KeptText-test.js => KeptText-test.jsx} | 2 - ...TextForm-test.js => KeptTextForm-test.jsx} | 2 - .../todo/{KeptTodo.js => KeptTodo.jsx} | 4 +- .../{KeptTodoForm.js => KeptTodoForm.jsx} | 21 +++++---- .../{KeptTodoTask.js => KeptTodoTask.jsx} | 4 +- ...ptTodoTaskForm.js => KeptTodoTaskForm.jsx} | 13 +++--- .../{KeepTodo-test.js => KeepTodo-test.jsx} | 2 - src/js/{kept.js => kept.jsx} | 5 +-- .../{Resize-test.js => Resize-test.jsx} | 2 - .../{UndoStack-test.js => UndoStack-test.jsx} | 2 - 28 files changed, 90 insertions(+), 118 deletions(-) create mode 100644 .eslintrc rename src/js/components/{DefaultContent.js => DefaultContent.jsx} (97%) rename src/js/components/{GlyphiconLink.js => GlyphiconLink.jsx} (57%) rename src/js/components/{KeptApp.js => KeptApp.jsx} (99%) rename src/js/components/{KeptColumns.js => KeptColumns.jsx} (90%) rename src/js/components/{KeptEntry.js => KeptEntry.jsx} (73%) rename src/js/components/{KeptItems.js => KeptItems.jsx} (95%) rename src/js/components/{KeptMenuBar.js => KeptMenuBar.jsx} (97%) rename src/js/components/__tests__/{DefaultContent-test.js => DefaultContent-test.jsx} (98%) rename src/js/components/__tests__/{KeptApp-test.js => KeptApp-test.jsx} (98%) rename src/js/components/__tests__/{KeptColumns-test.js => KeptColumns-test.jsx} (93%) rename src/js/components/__tests__/{KeptEntry-test.js => KeptEntry-test.jsx} (98%) rename src/js/components/__tests__/{KeptItems-test.js => KeptItems-test.jsx} (98%) rename src/js/components/text/{KeptText.js => KeptText.jsx} (95%) rename src/js/components/text/{KeptTextForm.js => KeptTextForm.jsx} (88%) rename src/js/components/text/__tests__/{KeptText-test.js => KeptText-test.jsx} (95%) rename src/js/components/text/__tests__/{KeptTextForm-test.js => KeptTextForm-test.jsx} (98%) rename src/js/components/todo/{KeptTodo.js => KeptTodo.jsx} (94%) rename src/js/components/todo/{KeptTodoForm.js => KeptTodoForm.jsx} (81%) rename src/js/components/todo/{KeptTodoTask.js => KeptTodoTask.jsx} (90%) rename src/js/components/todo/{KeptTodoTaskForm.js => KeptTodoTaskForm.jsx} (74%) rename src/js/components/todo/__tests__/{KeepTodo-test.js => KeepTodo-test.jsx} (98%) rename src/js/{kept.js => kept.jsx} (72%) rename src/js/mixins/__tests__/{Resize-test.js => Resize-test.jsx} (91%) rename src/js/mixins/__tests__/{UndoStack-test.js => UndoStack-test.jsx} (97%) diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..5d9ea45 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,6 @@ +{ + "env": { + "browser": true, + "node": true + } +} diff --git a/gulpfile.js b/gulpfile.js index 791c585..73de62b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -9,6 +9,8 @@ var source = require('vinyl-source-stream'); var uglify = require('gulp-uglify'); var deploy = require("gulp-gh-pages"); +var extend = require('util')._extend; + var opt = { outputFolder: "build", @@ -37,12 +39,16 @@ var opt = { ], app: { - src: "src/js/kept.js", + src: "src/js/kept.jsx", dest: "kept.js" }, vendors: "vendors.js" }; +var jsxOpt = { + extensions: ['.jsx'] +}; + /** * Assets tasks */ @@ -77,9 +83,11 @@ gulp.task("js", [ ]); gulp.task("js:app", ["js:vendors"], function() { - return browserify("./" + opt.app.src) - .transform("reactify") + return browserify(jsxOpt) + .add("./"+opt.app.src) + .transform("reactify", {global: true}) .external("react") + .external("react-dom") .external("react-bootstrap") .external("marked") .bundle() @@ -90,6 +98,7 @@ gulp.task("js:app", ["js:vendors"], function() { gulp.task("js:vendors", function() { return browserify() .require("react") + .require("react-dom") .require("react-bootstrap") .require("marked") .bundle() @@ -127,28 +136,23 @@ gulp.task("server", function() { */ gulp.task("watchify", function(){ + var args = extend(watchify.args, jsxOpt); - var b = browserify( "./" + opt.app.src , watchify.args) - .transform("reactify") + var b = browserify("./"+opt.app.src, args) + .transform("reactify", {global: true}) .external("react") + .external("react-dom") .external("react-bootstrap") .external("marked"); - - function updateBundle(w){ - - return w.bundle() + return watchify(b).on("update", function(){ + b.bundle() .pipe(source(opt.app.dest)) .pipe(gulp.dest(opt.outputFolder + "/js")); - } - - var watcher= watchify(b); - watcher.on("update", function(){ - updateBundle(watcher); - }); - - return updateBundle(watcher); - + }) + .bundle() + .pipe(source(opt.app.dest)) + .pipe(gulp.dest(opt.outputFolder + "/js")); }); @@ -181,6 +185,8 @@ gulp.task("deploy", ["dist"], function() { .pipe(deploy("git@github.com:n1k0/kept.git")); }); -gulp.task("default", ["server", "watch"], function(){ +gulp.task("default", ["server", "watch"], function(done){ + console.log("app running at http://"+opt.server.host+":"+opt.server.port); require('opn')("http://"+opt.server.host+":"+opt.server.port); + done(); }); diff --git a/package.json b/package.json index cbb5413..9745c18 100644 --- a/package.json +++ b/package.json @@ -27,25 +27,29 @@ }, "homepage": "https://github.com/n1k0/kept", "dependencies": { - "gulp": "^3.8.*", - "gulp-gh-pages": "^0.3.*", - "gulp-uglify": "^0.3.*", - "marked": "^0.3.*", - "react": "^0.10.*", - "react-bootstrap": "^0.10.*", - "reactify": "^0.13.*", - "vinyl-source-stream": "^0.1.*", - "watchify": "^1.0.6", - "browserify": "^6.0.2", + "browserify": "^11.0.1", "connect": "^3.3.3", "connect-livereload": "^0.5.2", + "gulp": "^3.8.*", + "gulp-gh-pages": "^0.5.*", + "gulp-uglify": "^1.4.*", + "marked": "^0.3.*", + "opn": "^3.0.2", + "react": "^0.14.0-beta3", + "react-bootstrap": "^0.25.100-react-pre.0", + "react-dom": "^0.14.0-beta3", + "reactify": "^1.1.*", "serve-static": "^1.7.1", "tiny-lr": "^0.1.4", - "opn": "^1.0.0" + "vinyl-source-stream": "^1.1.*", + "watchify": "^3.4.0" }, "devDependencies": { - "jest-cli": "latest", + "babel-jest": "^5.3.*", + "jest-cli": "^0.5.*", + "jshint-stylish": "^2.0.1", "jsxhint": "latest", + "jshint-stylish": "^1.0.0", "react-tools": "latest" } } diff --git a/src/css/kept.css b/src/css/kept.css index 3da7782..fc28243 100644 --- a/src/css/kept.css +++ b/src/css/kept.css @@ -57,10 +57,12 @@ body { .kept-modal .kept-panel .panel-heading { cursor: default; } - .kept-panel h3 a { - display: block; + .kept-panel h3 button { + display: inline-block; float: right; margin-left: .5em; + padding: 0; + color: #fff; } .targetted { diff --git a/src/js/components/DefaultContent.js b/src/js/components/DefaultContent.jsx similarity index 97% rename from src/js/components/DefaultContent.js rename to src/js/components/DefaultContent.jsx index c0eaf4a..c3c3fe8 100644 --- a/src/js/components/DefaultContent.js +++ b/src/js/components/DefaultContent.jsx @@ -1,5 +1,3 @@ -/** @jsx React.DOM */ - "use strict"; var React = require("react"); diff --git a/src/js/components/GlyphiconLink.js b/src/js/components/GlyphiconLink.jsx similarity index 57% rename from src/js/components/GlyphiconLink.js rename to src/js/components/GlyphiconLink.jsx index 185f5a6..320564e 100644 --- a/src/js/components/GlyphiconLink.js +++ b/src/js/components/GlyphiconLink.jsx @@ -1,14 +1,13 @@ -/** @jsx React.DOM */ - "use strict"; var React = require("react"); +var Button = require("react-bootstrap").Button; var Glyphicon = require("react-bootstrap").Glyphicon; var GlyphiconLink = React.createClass({ render: function() { - return this.transferPropsTo( - + return ( + ); } }); diff --git a/src/js/components/KeptApp.js b/src/js/components/KeptApp.jsx similarity index 99% rename from src/js/components/KeptApp.js rename to src/js/components/KeptApp.jsx index 067e4f7..bb54664 100644 --- a/src/js/components/KeptApp.js +++ b/src/js/components/KeptApp.jsx @@ -1,5 +1,3 @@ -/** @jsx React.DOM */ - "use strict"; var utils = require("../utils"); @@ -107,7 +105,6 @@ var KeptApp = React.createClass({ move: function(fromIndex, toIndex) { // permut don't mutate array, return a new array var items = utils.permut(this.state.items, fromIndex, toIndex); - this.save(items); }, diff --git a/src/js/components/KeptColumns.js b/src/js/components/KeptColumns.jsx similarity index 90% rename from src/js/components/KeptColumns.js rename to src/js/components/KeptColumns.jsx index ba9d479..ee77733 100644 --- a/src/js/components/KeptColumns.js +++ b/src/js/components/KeptColumns.jsx @@ -1,6 +1,3 @@ -/** - * @jsx React.DOM - */ "use strict"; var React = require("react"); @@ -15,6 +12,7 @@ var KeptColumns = React.createClass({ var key = index * this.props.columns + this.props.column; return {this.props.itemData.title || "Untitled"} - - + + ); return ( -
- + {this.getComponent(this.props.itemData)}
diff --git a/src/js/components/KeptItems.js b/src/js/components/KeptItems.jsx similarity index 95% rename from src/js/components/KeptItems.js rename to src/js/components/KeptItems.jsx index 64919d4..5d1cc98 100644 --- a/src/js/components/KeptItems.js +++ b/src/js/components/KeptItems.jsx @@ -1,5 +1,3 @@ -/** @jsx React.DOM */ - "use strict"; var utils = require("../utils"); @@ -19,7 +17,6 @@ var KeepItems = React.createClass({ }, onResize: function(event){ - console.log(event, event.target.innerWidth); var col = 1; if (this.state.columnsWidth > 0) { col = Math.floor(event.target.innerWidth / this.state.columnsWidth); @@ -48,6 +45,7 @@ var KeepItems = React.createClass({ return ( +
diff --git a/src/js/components/text/__tests__/KeptText-test.js b/src/js/components/text/__tests__/KeptText-test.jsx similarity index 95% rename from src/js/components/text/__tests__/KeptText-test.js rename to src/js/components/text/__tests__/KeptText-test.jsx index f102475..8996f70 100644 --- a/src/js/components/text/__tests__/KeptText-test.js +++ b/src/js/components/text/__tests__/KeptText-test.jsx @@ -1,5 +1,3 @@ -/** @jsx React.DOM */ - "use strict"; var TestUtils = require('react/addons').addons.TestUtils; diff --git a/src/js/components/text/__tests__/KeptTextForm-test.js b/src/js/components/text/__tests__/KeptTextForm-test.jsx similarity index 98% rename from src/js/components/text/__tests__/KeptTextForm-test.js rename to src/js/components/text/__tests__/KeptTextForm-test.jsx index e44f991..5055f35 100644 --- a/src/js/components/text/__tests__/KeptTextForm-test.js +++ b/src/js/components/text/__tests__/KeptTextForm-test.jsx @@ -1,5 +1,3 @@ -/** @jsx React.DOM */ - "use strict"; var TestUtils = require('react/addons').addons.TestUtils; diff --git a/src/js/components/todo/KeptTodo.js b/src/js/components/todo/KeptTodo.jsx similarity index 94% rename from src/js/components/todo/KeptTodo.js rename to src/js/components/todo/KeptTodo.jsx index cfb688d..7a56368 100644 --- a/src/js/components/todo/KeptTodo.js +++ b/src/js/components/todo/KeptTodo.jsx @@ -1,5 +1,3 @@ -/** @jsx React.DOM */ - "use strict"; var React = require("react"); @@ -56,7 +54,7 @@ var KeptTodo = React.createClass({
    { this.state.tasks.map(function(task, key) { - return ; + return ; }.bind(this)) }

Clear completed

diff --git a/src/js/components/todo/KeptTodoForm.js b/src/js/components/todo/KeptTodoForm.jsx similarity index 81% rename from src/js/components/todo/KeptTodoForm.js rename to src/js/components/todo/KeptTodoForm.jsx index 74fd5d4..c1b5525 100644 --- a/src/js/components/todo/KeptTodoForm.js +++ b/src/js/components/todo/KeptTodoForm.jsx @@ -1,8 +1,7 @@ -/** @jsx React.DOM */ - "use strict"; var React = require("react"); +var reactDom = require("react-dom"); var Modal = require("react-bootstrap").Modal; var KeptTodoTaskForm = require("./KeptTodoTaskForm"); @@ -27,7 +26,7 @@ var KeptTodoForm = React.createClass({ }, focusLatestInput: function() { - var inputs = this.getDOMNode().querySelectorAll("input[type=text]"); + var inputs = this.refs.tasks.querySelectorAll("input[type=text]"); inputs[inputs.length - 1].focus(); }, @@ -35,14 +34,15 @@ var KeptTodoForm = React.createClass({ this.props.resetForm(); }, - handleSubmit: function() { - var id = parseInt(this.refs.id.getDOMNode().value.trim(), 10); + handleSave: function() { + var id = parseInt(this.refs.id.value.trim(), 10); var process = id ? this.props.update : this.props.create; process({ type: "todo", id: id, - title: this.refs.title.getDOMNode().value.trim(), + title: this.refs.title.value.trim(), tasks: (this.state.tasks || []).filter(function(task) { + console.log(task.label) return !!task.label; }) }); @@ -69,9 +69,8 @@ var KeptTodoForm = React.createClass({ }, render: function() { - console.log("---"); return ( - +
@@ -79,9 +78,9 @@ var KeptTodoForm = React.createClass({
-
    { +
      { this.state.tasks.map(function(task, key) { - return ; }, this) }
    @@ -89,7 +88,7 @@ var KeptTodoForm = React.createClass({
      - +   Cancel
    diff --git a/src/js/components/todo/KeptTodoTask.js b/src/js/components/todo/KeptTodoTask.jsx similarity index 90% rename from src/js/components/todo/KeptTodoTask.js rename to src/js/components/todo/KeptTodoTask.jsx index da1a582..0474a13 100644 --- a/src/js/components/todo/KeptTodoTask.js +++ b/src/js/components/todo/KeptTodoTask.jsx @@ -1,12 +1,10 @@ -/** @jsx React.DOM */ - "use strict"; var React = require("react"); var KeptTodoTask = React.createClass({ handleChange: function() { - this.props.toggle(this.props.key); + this.props.toggle(this.props.index); }, render: function() { diff --git a/src/js/components/todo/KeptTodoTaskForm.js b/src/js/components/todo/KeptTodoTaskForm.jsx similarity index 74% rename from src/js/components/todo/KeptTodoTaskForm.js rename to src/js/components/todo/KeptTodoTaskForm.jsx index 31ab150..0bd1b22 100644 --- a/src/js/components/todo/KeptTodoTaskForm.js +++ b/src/js/components/todo/KeptTodoTaskForm.jsx @@ -1,25 +1,22 @@ -/** @jsx React.DOM */ - "use strict"; var React = require("react"); var KeptTodoTaskForm = React.createClass({ - handleUpdate: function() { - this.props.updateTask(this.props.key, { - label: this.refs.label.getDOMNode().value.trim(), - done: this.refs.done.getDOMNode().checked + handleUpdate: function(event) { + this.props.updateTask(this.props.index, { + label: this.refs.label.value.trim(), + done: this.refs.done.checked }); }, handleRemove: function(event) { event.preventDefault(); - this.props.removeTask(this.props.key); + this.props.removeTask(this.props.index); }, render: function() { var data = this.props.data; - console.log("rendering KeptTodoTaskForm", data.label); var checkedValue = data.done ? "checked" : ""; return (
  • diff --git a/src/js/components/todo/__tests__/KeepTodo-test.js b/src/js/components/todo/__tests__/KeepTodo-test.jsx similarity index 98% rename from src/js/components/todo/__tests__/KeepTodo-test.js rename to src/js/components/todo/__tests__/KeepTodo-test.jsx index 18805f3..5e2a040 100644 --- a/src/js/components/todo/__tests__/KeepTodo-test.js +++ b/src/js/components/todo/__tests__/KeepTodo-test.jsx @@ -1,5 +1,3 @@ -/** @jsx React.DOM */ - "use strict"; var TestUtils = require('react/addons').addons.TestUtils; diff --git a/src/js/kept.js b/src/js/kept.jsx similarity index 72% rename from src/js/kept.js rename to src/js/kept.jsx index d8ff739..88facd0 100644 --- a/src/js/kept.js +++ b/src/js/kept.jsx @@ -1,11 +1,10 @@ -/** @jsx React.DOM */ - "use strict"; var React = require("react"); +var reactDom = require("react-dom"); var KeptApp = require("./components/KeptApp"); var KeptStore = require("./store"); var store = new KeptStore(); -React.renderComponent(, +reactDom.render(, document.getElementById('kept')); diff --git a/src/js/mixins/__tests__/Resize-test.js b/src/js/mixins/__tests__/Resize-test.jsx similarity index 91% rename from src/js/mixins/__tests__/Resize-test.js rename to src/js/mixins/__tests__/Resize-test.jsx index 5b8313d..381d62f 100644 --- a/src/js/mixins/__tests__/Resize-test.js +++ b/src/js/mixins/__tests__/Resize-test.jsx @@ -1,5 +1,3 @@ -/** @jsx React.DOM */ - "use strict"; var React = require("react"); diff --git a/src/js/mixins/__tests__/UndoStack-test.js b/src/js/mixins/__tests__/UndoStack-test.jsx similarity index 97% rename from src/js/mixins/__tests__/UndoStack-test.js rename to src/js/mixins/__tests__/UndoStack-test.jsx index d5d216d..6222d87 100644 --- a/src/js/mixins/__tests__/UndoStack-test.js +++ b/src/js/mixins/__tests__/UndoStack-test.jsx @@ -1,5 +1,3 @@ -/** @jsx React.DOM */ - "use strict"; var React = require("react"); From 8a0cd15c4f4701161c2f57f9b2d81f7da9f5793a Mon Sep 17 00:00:00 2001 From: Lionel Breduillieard Date: Sat, 12 Sep 2015 18:28:28 +0200 Subject: [PATCH 3/4] remove jshint/ jsxhint and use eslint with react plugin --- .eslintrc | 36 +++++++++- .jshintrc | 30 -------- .jsxhintignore | 2 - .travis.yml | 2 +- jest-config-win.json | 7 -- jest-config.json | 7 -- package.json | 19 ++--- preprocessor.js | 7 -- src/js/components/KeptEntry.jsx | 4 +- .../__tests__/DefaultContent-test.jsx | 70 ++++++++++++------- src/js/components/__tests__/KeptApp-test.jsx | 35 ++++++---- .../components/__tests__/KeptColumns-test.jsx | 11 ++- .../components/__tests__/KeptEntry-test.jsx | 36 +++++----- .../components/__tests__/KeptItems-test.jsx | 16 ++--- src/js/components/text/KeptText.jsx | 2 +- src/js/components/text/KeptTextForm.jsx | 23 +++--- .../text/__tests__/KeptText-test.jsx | 25 +++---- .../text/__tests__/KeptTextForm-test.jsx | 40 ++++++----- src/js/components/todo/KeptTodo.jsx | 2 +- src/js/components/todo/KeptTodoForm.jsx | 27 +++---- .../todo/__tests__/KeepTodo-test.jsx | 30 ++++---- src/js/mixins/Resize.js | 58 +++++++-------- src/js/mixins/__tests__/Resize-test.jsx | 13 ++-- src/js/mixins/__tests__/UndoStack-test.jsx | 15 ++-- src/js/utils/__tests__/utils-test.js | 20 +++--- test/dom.js | 7 ++ test/mocha.opts | 3 + 27 files changed, 281 insertions(+), 266 deletions(-) delete mode 100644 .jshintrc delete mode 100644 .jsxhintignore delete mode 100644 jest-config-win.json delete mode 100644 jest-config.json delete mode 100644 preprocessor.js create mode 100644 test/dom.js create mode 100644 test/mocha.opts diff --git a/.eslintrc b/.eslintrc index 5d9ea45..4521258 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,6 +1,36 @@ { + "rules": { + "indent": [ + 2, + 2 + ], + "quotes": [ + 2, + "double" + ], + "linebreak-style": [ + 2, + "unix" + ], + "semi": [ + 2, + "always" + ], + "no-console": [ + 1 + ] + + }, "env": { "browser": true, - "node": true - } -} + "node": true, + "mocha": true + }, + "extends": "eslint:recommended", + "ecmaFeatures": { + "jsx": true + }, + "plugins": [ + "react" + ] +} \ No newline at end of file diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index e49f99c..0000000 --- a/.jshintrc +++ /dev/null @@ -1,30 +0,0 @@ -{ - "browser": true, - "camelcase": true, - "devel": true, - "eqeqeq": true, - "globalstrict": true, - "immed": false, - "indent": 2, - "jquery": true, - "latedef": true, - "maxlen": 120, - "newcap": false, - "node": true, - "strict": true, - "trailing": false, - "undef": true, - "unused": "vars", - - "predef": [ - "jasmine", - "jest", - "describe", - "it", - "expect", - "before", - "beforeEach", - "after", - "afterEach" - ] -} diff --git a/.jsxhintignore b/.jsxhintignore deleted file mode 100644 index e3fbd98..0000000 --- a/.jsxhintignore +++ /dev/null @@ -1,2 +0,0 @@ -build -node_modules diff --git a/.travis.yml b/.travis.yml index 6e5919d..63f7b35 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,3 @@ language: node_js node_js: - - "0.10" + - "4" diff --git a/jest-config-win.json b/jest-config-win.json deleted file mode 100644 index 3be128c..0000000 --- a/jest-config-win.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "collectCoverage": true, - "scriptPreprocessor": "preprocessor.js", - "unmockedModulePathPatterns": [ - "react" - ] -} diff --git a/jest-config.json b/jest-config.json deleted file mode 100644 index f61be74..0000000 --- a/jest-config.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "collectCoverage": true, - "scriptPreprocessor": "/preprocessor.js", - "unmockedModulePathPatterns": [ - "/node_modules/react" - ] -} diff --git a/package.json b/package.json index 9745c18..29ff3e2 100644 --- a/package.json +++ b/package.json @@ -6,10 +6,10 @@ "scripts": { "deploy": "gulp deploy", "dist": "gulp dist", - "lint": "jsxhint -c .jshintrc src/js", + "lint": "eslint src", "start": "gulp", - "test": " npm run lint && jest --config jest-config.json", - "test-win": "npm run lint && jest --config jest-config-win.json" + "test": "mocha src/**/__tests__/*", + "tdd": "mocha --watch ./src/**/__tests__/*.*" }, "repository": { "type": "git", @@ -45,11 +45,12 @@ "watchify": "^3.4.0" }, "devDependencies": { - "babel-jest": "^5.3.*", - "jest-cli": "^0.5.*", - "jshint-stylish": "^2.0.1", - "jsxhint": "latest", - "jshint-stylish": "^1.0.0", - "react-tools": "latest" + "babel": "^5.8.23", + "chai": "^3.2.0", + "eslint": "^1.4.1", + "eslint-plugin-react": "^3.3.2", + "jsdom": "^6.3.0", + "mocha": "^2.3.2", + "sinon": "^1.16.1" } } diff --git a/preprocessor.js b/preprocessor.js deleted file mode 100644 index 32f4a00..0000000 --- a/preprocessor.js +++ /dev/null @@ -1,7 +0,0 @@ -var ReactTools = require('react-tools'); - -module.exports = { - process: function(src) { - return ReactTools.transform(src); - } -}; diff --git a/src/js/components/KeptEntry.jsx b/src/js/components/KeptEntry.jsx index bad1648..1f0c5ba 100644 --- a/src/js/components/KeptEntry.jsx +++ b/src/js/components/KeptEntry.jsx @@ -75,8 +75,8 @@ var KeptEntry = React.createClass({ var panelHeader = (

    {this.props.itemData.title || "Untitled"} - - + +

    ); return ( diff --git a/src/js/components/__tests__/DefaultContent-test.jsx b/src/js/components/__tests__/DefaultContent-test.jsx index 055e0fb..113ad00 100644 --- a/src/js/components/__tests__/DefaultContent-test.jsx +++ b/src/js/components/__tests__/DefaultContent-test.jsx @@ -1,41 +1,57 @@ "use strict"; -var TestUtils = require('react/addons').addons.TestUtils; - -jest.dontMock('../DefaultContent'); -var DefaultContent = require('../DefaultContent'); - -describe("#render", function() { - var comp; +var React = require("react"); +var TestUtils = require("react/lib/ReactTestUtils"); +var sinon = require("sinon"); +var expect = require("chai").expect; + +var DefaultContent = require("../DefaultContent"); +describe("DefaultContent", function() { + describe("#render", function() { + var renderer = TestUtils.createRenderer(); + var result; + beforeEach(function() { + renderer.render( + + ); + result = renderer.getRenderOutput(); + }); + + it("should render HTML content", function() { + expect(result.props.children.length > 0).to.be.true; + }); + }); - var fakeCreateText = jasmine.createSpy("fakeCreateText"); - var fakeCreateTodo = jasmine.createSpy("fakeCreateTodo"); + describe("add default items", function() { + var comp; + var fakeCreateText = sinon.spy(); + var fakeCreateTodo = sinon.spy(); - function fakeNewItem(type) { - return type === "text" ? fakeCreateText : fakeCreateTodo; - } + function fakeNewItem(type) { + return type === "text" ? fakeCreateText : fakeCreateTodo; + } - beforeEach(function() { - comp = TestUtils.renderIntoDocument(); - }); + beforeEach(function() { + comp = TestUtils.renderIntoDocument( + + ); + }); - it("should render HTML content", function() { - expect(comp.getDOMNode().outerHTML.length > 0).toBe(true); - }); + it("should add a new text entry when clicking on Text link", function() { - it("should add a new text entry when clicking on Text link", function() { - var newTextLink = TestUtils.findRenderedDOMComponentWithClass(comp, "new-text"); + var newTextLink = TestUtils.findRenderedDOMComponentWithClass(comp, "new-text"); - TestUtils.Simulate.click(newTextLink); + TestUtils.Simulate.click(newTextLink); - expect(fakeCreateText).toHaveBeenCalled(); - }); + expect(fakeCreateText.calledOnce).to.be.true; + }); - it("should add a new todo entry when clicking on Todo link", function() { - var newTodoLink = TestUtils.findRenderedDOMComponentWithClass(comp, "new-todo"); + it("should add a new todo entry when clicking on Todo link", function() { + var newTodoLink = TestUtils.findRenderedDOMComponentWithClass(comp, "new-todo"); - TestUtils.Simulate.click(newTodoLink); + TestUtils.Simulate.click(newTodoLink); - expect(fakeCreateTodo).toHaveBeenCalled(); + expect(fakeCreateTodo.calledOnce).to.be.true; + }); }); }); diff --git a/src/js/components/__tests__/KeptApp-test.jsx b/src/js/components/__tests__/KeptApp-test.jsx index ee4aa0c..a8aed1d 100644 --- a/src/js/components/__tests__/KeptApp-test.jsx +++ b/src/js/components/__tests__/KeptApp-test.jsx @@ -1,18 +1,16 @@ "use strict"; -var TestUtils = require('react/addons').addons.TestUtils; +var TestUtils = require("react/lib/ReactTestUtils"); +var React = require("react"); +var expect = require("chai").expect; +var renderer = TestUtils.createRenderer(); -jest.dontMock('../KeptMenuBar'); -jest.dontMock('../text/KeptTextForm'); -jest.dontMock('../todo/KeptTodoForm'); -jest.dontMock('../KeptApp'); - -var KeptApp = require('../KeptApp'); +var KeptApp = require("../KeptApp"); var KeptTextForm = require("../text/KeptTextForm"); var KeptTodoForm = require("../todo/KeptTodoForm"); describe("KeptApp", function() { - var comp, fakeStore; + var fakeStore; beforeEach(function() { fakeStore = { @@ -22,19 +20,28 @@ describe("KeptApp", function() { save: function() { } }; - comp = TestUtils.renderIntoDocument(); }); describe("#render", function() { it("should render HTML content", function() { - expect(comp.getDOMNode().outerHTML.length > 0).toBe(true); + renderer.render( + + ); + var dom = renderer.getRenderOutput(); + expect(dom.props.children.length).to.be.above(0); }); }); describe("#formCreator", function() { + var comp; + + beforeEach(function() { + comp = TestUtils.renderIntoDocument(); + }); + it("should generate a form creation function", function() { - expect(typeof comp.formCreator("text")).toEqual("function"); - expect(typeof comp.formCreator("todo")).toEqual("function"); + expect(comp.formCreator("text")).to.be.a("function"); + expect(comp.formCreator("todo")).to.be.a("function"); }); it("should add a text form component to state", function() { @@ -42,7 +49,7 @@ describe("KeptApp", function() { textForm({}); - expect(TestUtils.isComponentOfType(comp.state.form, KeptTextForm)).toBe(true); + //expect(TestUtils.isComponentOfType(comp.state.form, KeptTextForm)).to.be.true; }); it("should add a todo form component to state", function() { @@ -50,7 +57,7 @@ describe("KeptApp", function() { todoForm({}); - expect(TestUtils.isComponentOfType(comp.state.form, KeptTodoForm)).toBe(true); + //expect(TestUtils.isComponentOfType(comp.state.form, KeptTodoForm)).to.be.true; }); }); }); diff --git a/src/js/components/__tests__/KeptColumns-test.jsx b/src/js/components/__tests__/KeptColumns-test.jsx index c5dfa30..2139d06 100644 --- a/src/js/components/__tests__/KeptColumns-test.jsx +++ b/src/js/components/__tests__/KeptColumns-test.jsx @@ -1,9 +1,8 @@ "use strict"; -var TestUtils = require('react/addons').addons.TestUtils; - -jest.dontMock('../KeptEntry'); -jest.dontMock('../KeptColumns'); +var React = require("react"); +var TestUtils = require("react/lib/ReactTestUtils"); +var expect = require("chai").expect; var KeptEntry = require("../KeptEntry"); var KeptColumns = require("../KeptColumns"); @@ -15,7 +14,7 @@ describe("KeptColumns", function() { var items = [ {id: 1, type: "text", text: "text id #1"}, {id: 2, type: "text", text: "text id #2"}, - {id: 3, type: "text", text: "text id #3"}, + {id: 3, type: "text", text: "text id #3"} ]; var columns = 3; var col = 1; @@ -23,7 +22,7 @@ describe("KeptColumns", function() { var comp = TestUtils.renderIntoDocument(); var entries = TestUtils.scryRenderedComponentsWithType(comp, KeptEntry); - expect(entries.length).toEqual(3); + expect(entries.length).to.equal(3); }); }); }); diff --git a/src/js/components/__tests__/KeptEntry-test.jsx b/src/js/components/__tests__/KeptEntry-test.jsx index e979a62..8c0c916 100644 --- a/src/js/components/__tests__/KeptEntry-test.jsx +++ b/src/js/components/__tests__/KeptEntry-test.jsx @@ -1,14 +1,11 @@ "use strict"; -var TestUtils = require('react/addons').addons.TestUtils; +var React = require("react"); +var reactDom = require("react-dom"); +var TestUtils = require("react/lib/ReactTestUtils"); +var expect = require("chai").expect; +var sinon = require("sinon"); -jest.dontMock('react-bootstrap/Panel'); -jest.dontMock('../KeptEntry'); -jest.dontMock('../GlyphiconLink'); -jest.dontMock('../text/KeptText'); -jest.dontMock('../todo/KeptTodo'); -var KeptEntry = require("react-bootstrap/Panel"); -var KeptEntry = require("../GlyphiconLink"); var KeptEntry = require("../KeptEntry"); var KeptText = require("../text/KeptText"); var KeptTodo = require("../todo/KeptTodo"); @@ -17,18 +14,17 @@ describe("KeptEntry", function() { var comp, fakeUpdate, fakeEdit; function renderWithProps(props) { - return TestUtils.renderIntoDocument(KeptEntry(props)); + return TestUtils.renderIntoDocument( + + ); } beforeEach(function() { - fakeUpdate = jest.genMockFn(); - fakeEdit = jest.genMockFn(); + fakeUpdate = sinon.spy(); + fakeEdit = sinon.spy(); }); - afterEach(function() { - fakeUpdate.mockClear(); - fakeEdit.mockClear(); - }); + describe("#handleClickEdit", function() { it("should call edit", function() { @@ -43,14 +39,14 @@ describe("KeptEntry", function() { edit: fakeEdit }); - TestUtils.Simulate.click(comp.getDOMNode().querySelector("h3 a.edit")); + TestUtils.Simulate.click(reactDom.findDOMNode(comp.refs.editBt)); - expect(fakeEdit).lastCalledWith({ + expect(fakeEdit.calledWith({ type: "text", id: 42, title: "test text", text: "text" - }); + })).to.be.true; }); }); @@ -63,7 +59,7 @@ describe("KeptEntry", function() { text: "text" }}); - expect(TestUtils.findRenderedComponentWithType(comp, KeptText)).toBeTruthy(); + expect(TestUtils.findRenderedComponentWithType(comp, KeptText)).to.be.ok; }); it("should render a todo entry", function() { @@ -78,7 +74,7 @@ describe("KeptEntry", function() { update: fakeUpdate }); - expect(TestUtils.findRenderedComponentWithType(comp, KeptTodo)).toBeTruthy(); + expect(TestUtils.findRenderedComponentWithType(comp, KeptTodo)).to.be.ok; }); }); }); diff --git a/src/js/components/__tests__/KeptItems-test.jsx b/src/js/components/__tests__/KeptItems-test.jsx index af44e1d..9bc8d29 100644 --- a/src/js/components/__tests__/KeptItems-test.jsx +++ b/src/js/components/__tests__/KeptItems-test.jsx @@ -1,10 +1,9 @@ "use strict"; -var TestUtils = require('react/addons').addons.TestUtils; - -jest.dontMock('../KeptItems'); -jest.dontMock('../DefaultContent'); -jest.dontMock('../KeptColumns'); +var React = require("react"); +var TestUtils = require("react/lib/ReactTestUtils"); +var expect = require("chai").expect; +var sinon = require("sinon"); var KeptItems = require("../KeptItems"); var DefaultContent = require("../DefaultContent"); @@ -15,9 +14,10 @@ var range = require('../../utils').range; describe("KeptItems", function() { describe("#render", function() { var array = [1,2,3]; - + var range; beforeEach(function(){ - range.mockReturnValue(array); + range = sinon.stub(); + range.returns(array); }); it("should render default content when items list is empty", function() { @@ -42,7 +42,7 @@ describe("KeptItems", function() { var entries = TestUtils.scryRenderedComponentsWithType(comp, KeptColumns); - expect(entries.length).toEqual(array.length); + expect(entries.length).to.equal(array.length); }); }); }); diff --git a/src/js/components/text/KeptText.jsx b/src/js/components/text/KeptText.jsx index 22b560e..5ee7680 100644 --- a/src/js/components/text/KeptText.jsx +++ b/src/js/components/text/KeptText.jsx @@ -18,7 +18,7 @@ var KeptText = React.createClass({ render: function() { return (
    -
    ); diff --git a/src/js/components/text/KeptTextForm.jsx b/src/js/components/text/KeptTextForm.jsx index 3256cb6..9abf713 100644 --- a/src/js/components/text/KeptTextForm.jsx +++ b/src/js/components/text/KeptTextForm.jsx @@ -42,9 +42,10 @@ var KeptTextForm = React.createClass({ render: function() { return ( - - -
    + + Create new Text + +
    -
    -
    - -   - Cancel -
    - -
    + + + + +   + Cancel + + ); } }); diff --git a/src/js/components/text/__tests__/KeptText-test.jsx b/src/js/components/text/__tests__/KeptText-test.jsx index 8996f70..d6d1627 100644 --- a/src/js/components/text/__tests__/KeptText-test.jsx +++ b/src/js/components/text/__tests__/KeptText-test.jsx @@ -1,20 +1,21 @@ "use strict"; -var TestUtils = require('react/addons').addons.TestUtils; +var React = require("react"); +var TestUtils = require("react/lib/ReactTestUtils"); +var expect = require("chai").expect; -jest.dontMock('marked'); -jest.dontMock('../KeptText'); var KeptText = require('../KeptText'); +describe("KeptText", function(){ + describe("#render", function() { + var comp; -describe("#render", function() { - var comp; + beforeEach(function() { + var data = {type: "text", text: "# plop"}; + comp = TestUtils.renderIntoDocument(); + }); - beforeEach(function() { - var data = {type: "text", text: "# plop"}; - comp = TestUtils.renderIntoDocument(); - }); - - it("should render markdown text as HTML", function() { - expect(comp.getDOMNode().querySelector("h1").textContent).toEqual("plop"); + it("should render markdown text as HTML", function() { + expect(comp.refs.content.querySelector("h1").textContent).to.equal("plop"); + }); }); }); diff --git a/src/js/components/text/__tests__/KeptTextForm-test.jsx b/src/js/components/text/__tests__/KeptTextForm-test.jsx index 5055f35..f29a966 100644 --- a/src/js/components/text/__tests__/KeptTextForm-test.jsx +++ b/src/js/components/text/__tests__/KeptTextForm-test.jsx @@ -1,10 +1,12 @@ "use strict"; -var TestUtils = require('react/addons').addons.TestUtils; +var React = require("react"); +var reactDom = require("react-dom"); +var TestUtils = require("react/lib/ReactTestUtils"); +var expect = require("chai").expect; +var sinon = require("sinon"); -jest.dontMock('react-bootstrap'); -jest.dontMock('../KeptTextForm'); -var KeptTextForm = require('../KeptTextForm'); +var KeptTextForm = require("../KeptTextForm"); describe("KeptTextForm", function() { var fakeCreate, fakeUpdate; @@ -17,14 +19,16 @@ describe("KeptTextForm", function() { }; beforeEach(function() { - fakeCreate = jest.genMockFn(); - fakeUpdate = jest.genMockFn(); + fakeCreate = sinon.spy(); + fakeUpdate = sinon.spy(); }); describe("#handleSubmit", function() { it("should create a new text", function() { var comp = TestUtils.renderIntoDocument( - ); + + ); + var form = comp.getDOMNode().querySelector("form"); TestUtils.Simulate.change(form.querySelector("input[type=text]"), @@ -33,39 +37,41 @@ describe("KeptTextForm", function() { {target: {value: "# world"}}); TestUtils.Simulate.submit(form); - expect(fakeCreate).toBeCalledWith({ + expect(fakeCreate.calledWith({ id: null, type: "text", title: "Hello", text: "# world" - }); + })).to.be.true; }); it("should update an existing text", function() { var comp = TestUtils.renderIntoDocument( ); - var form = comp.getDOMNode().querySelector("form"); - TestUtils.Simulate.change(form.querySelector("input[type=text]"), + TestUtils.Simulate.change(reactDom.findDOMNode(comp.refs.title) , {target: {value: "Plip"}}); - TestUtils.Simulate.change(form.querySelector("textarea"), + TestUtils.Simulate.change(reactDom.findDOMNode(comp.refs.text), {target: {value: "# plip"}}); - TestUtils.Simulate.submit(form); + TestUtils.Simulate.submit(reactDom.findDOMNode(comp.refs.title).form); - expect(fakeUpdate).toBeCalledWith({ + expect(fakeUpdate.calledWith({ id: 1, type: "text", title: "Plip", text: "# plip" - }); + })).to.be.true; }); }); describe("#render", function() { it("should render HTML content", function() { - var comp = TestUtils.renderIntoDocument(); + var renderer = TestUtils.createRenderer(); + renderer.render(); + + var result = renderer.getRenderOutput(); - expect(comp.getDOMNode().querySelector("form")).toBeTruthy(); + expect(result.props.children.length).to.equal(3); }); }); }); diff --git a/src/js/components/todo/KeptTodo.jsx b/src/js/components/todo/KeptTodo.jsx index 7a56368..558a47e 100644 --- a/src/js/components/todo/KeptTodo.jsx +++ b/src/js/components/todo/KeptTodo.jsx @@ -52,7 +52,7 @@ var KeptTodo = React.createClass({ return (
    -
      { +
        { this.state.tasks.map(function(task, key) { return ; }.bind(this)) diff --git a/src/js/components/todo/KeptTodoForm.jsx b/src/js/components/todo/KeptTodoForm.jsx index c1b5525..bf70ac2 100644 --- a/src/js/components/todo/KeptTodoForm.jsx +++ b/src/js/components/todo/KeptTodoForm.jsx @@ -70,9 +70,10 @@ var KeptTodoForm = React.createClass({ render: function() { return ( - -
        -
        + + Create new Todo + +
        ; }, this) }
      -
    -
    - -   - -   - Cancel -
    - - + + + + +   + +   + Cancel + + ); } }); diff --git a/src/js/components/todo/__tests__/KeepTodo-test.jsx b/src/js/components/todo/__tests__/KeepTodo-test.jsx index 5e2a040..5c67e89 100644 --- a/src/js/components/todo/__tests__/KeepTodo-test.jsx +++ b/src/js/components/todo/__tests__/KeepTodo-test.jsx @@ -1,21 +1,21 @@ "use strict"; -var TestUtils = require('react/addons').addons.TestUtils; +var React = require("react"); +var TestUtils = require("react/lib/ReactTestUtils"); +var expect = require("chai").expect; +var sinon = require("sinon"); -jest.dontMock('../KeptTodoTask'); -jest.dontMock('../KeptTodo'); -jest.dontMock('react-bootstrap/ProgressBar'); -var KeptTodo = require('../KeptTodo'); +var KeptTodo = require("../KeptTodo"); describe("KeptTodo", function() { var comp, fakeUpdate; function renderWithProps(props) { - return TestUtils.renderIntoDocument(KeptTodo(props)); + return TestUtils.renderIntoDocument( ); } beforeEach(function() { - fakeUpdate = jest.genMockFn(); + fakeUpdate = sinon.spy(); comp = renderWithProps({ update: fakeUpdate, data: { @@ -32,22 +32,22 @@ describe("KeptTodo", function() { }); afterEach(function() { - fakeUpdate.mockClear(); + fakeUpdate.reset(); }); describe("#getProgress", function() { it("should compute task completion percentage", function() { - expect(comp.getDOMNode().querySelector('[aria-valuenow="33"]')).toBeTruthy(); + expect(comp.getDOMNode().querySelector('[aria-valuenow="33"]')).to.be.ok; }); }); describe("#toggle", function() { it("should toggle a given task status", function() { - var checkboxes = comp.getDOMNode().querySelectorAll(".list-group-item input[type=checkbox]"); + var checkboxes = comp.refs.taskItems.querySelectorAll(".list-group-item input[type=checkbox]"); TestUtils.Simulate.change(checkboxes[1]); // second one, key=1 - expect(fakeUpdate).lastCalledWith({ + expect(fakeUpdate.calledWith({ type: "todo", id: 1, title: "todo", @@ -56,7 +56,7 @@ describe("KeptTodo", function() { {label: "todo2", done: false}, {label: "todo3", done: false} ] - }); + })).to.be.true; }); }); @@ -66,7 +66,7 @@ describe("KeptTodo", function() { TestUtils.Simulate.click(clearLink); - expect(fakeUpdate).lastCalledWith({ + expect(fakeUpdate.calledWith({ type: "todo", id: 1, title: "todo", @@ -74,13 +74,13 @@ describe("KeptTodo", function() { {label: "todo1", done: false}, {label: "todo3", done: false} ] - }); + })).to.be.true; }); }); describe("#render", function() { it("should render expected amount of entries", function() { - expect(comp.getDOMNode().querySelectorAll(".list-group-item").length).toEqual(3); + expect(comp.refs.taskItems.querySelectorAll(".list-group-item").length).to.equal(3); }); }); }); diff --git a/src/js/mixins/Resize.js b/src/js/mixins/Resize.js index d06b57a..c10c7a5 100644 --- a/src/js/mixins/Resize.js +++ b/src/js/mixins/Resize.js @@ -1,29 +1,29 @@ -"use strict"; - -var Resize = { - componentDidMount: function() { - // checking if we are inside a browser - if (!window) { - return; - } - - window.addEventListener('resize', this._onResize); - this._onResize({target:window}); - }, - - componentWillUnmount: function() { - // checking if we are inside a browser - if (!window) { - return; - } - - window.removeEventListener('resize', this._onResize); - }, - - _onResize: function(event){ - if (typeof this.onResize !== "function") return; - this.onResize(event); - } -}; - -module.exports = Resize; +"use strict"; + +var Resize = { + componentDidMount: function() { + // checking if we are inside a browser + if (!window) { + return; + } + + window.addEventListener("resize", this._onResize); + this._onResize({target:window}); + }, + + componentWillUnmount: function() { + // checking if we are inside a browser + if (!window) { + return; + } + + window.removeEventListener("resize", this._onResize); + }, + + _onResize: function(event){ + if (typeof this.onResize !== "function") return; + this.onResize(event); + } +}; + +module.exports = Resize; diff --git a/src/js/mixins/__tests__/Resize-test.jsx b/src/js/mixins/__tests__/Resize-test.jsx index 381d62f..402584d 100644 --- a/src/js/mixins/__tests__/Resize-test.jsx +++ b/src/js/mixins/__tests__/Resize-test.jsx @@ -1,17 +1,17 @@ "use strict"; var React = require("react"); -var TestUtils = require('react/addons').addons.TestUtils; +var TestUtils = require("react/lib/ReactTestUtils"); +var expect = require("chai").expect; -jest.dontMock('../Resize'); -var Resize = require('../Resize'); +var Resize = require("../Resize"); var TestComp = React.createClass({ mixins: [Resize], getInitialState: function() { return { - columns: 1, + columns: 1 }; }, @@ -28,11 +28,10 @@ describe("Columns", function(){ var compo; beforeEach(function() { - compo = ; - TestUtils.renderIntoDocument(compo); + compo = TestUtils.renderIntoDocument(); }); it("should have a state columns", function(){ - expect(compo.state.columns).toBe(3); + expect(compo.state.columns).to.equal(3); }); }); \ No newline at end of file diff --git a/src/js/mixins/__tests__/UndoStack-test.jsx b/src/js/mixins/__tests__/UndoStack-test.jsx index 6222d87..3f428e9 100644 --- a/src/js/mixins/__tests__/UndoStack-test.jsx +++ b/src/js/mixins/__tests__/UndoStack-test.jsx @@ -1,10 +1,10 @@ "use strict"; var React = require("react"); -var TestUtils = require('react/addons').addons.TestUtils; +var TestUtils = require("react/lib/ReactTestUtils"); +var expect = require("chai").expect; -jest.dontMock('../UndoStack'); -var UndoStack = require('../UndoStack'); +var UndoStack = require("../UndoStack"); var TestComp = React.createClass({ mixins: [UndoStack], @@ -30,18 +30,17 @@ describe("UndoStack", function() { var comp; beforeEach(function() { - comp = ; - TestUtils.renderIntoDocument(comp); + comp = TestUtils.renderIntoDocument(); comp.snapshot(); }); it("should undo", function() { comp.setState({text: "v2"}); - expect(comp.state.text).toEqual("v2"); + expect(comp.state.text).to.equal("v2"); comp.undo(); - expect(comp.state.text).toEqual("v1"); + expect(comp.state.text).to.equal("v1"); }); it("should redo", function() { @@ -50,6 +49,6 @@ describe("UndoStack", function() { comp.redo(); - expect(comp.state.text).toEqual("v2"); + expect(comp.state.text).to.equal("v2"); }); }); diff --git a/src/js/utils/__tests__/utils-test.js b/src/js/utils/__tests__/utils-test.js index eb4ac52..c33c9ad 100644 --- a/src/js/utils/__tests__/utils-test.js +++ b/src/js/utils/__tests__/utils-test.js @@ -1,7 +1,9 @@ "use strict"; -jest.dontMock('..'); -var utils = require('..'); +var expect = require("chai").expect; + +var utils = require("../index.js"); + describe("nextId", function() { var items; @@ -11,23 +13,23 @@ describe("nextId", function() { }); it("should create a next id if items list is empty", function() { - expect(utils.nextId([])).toEqual(1); + expect(utils.nextId([])).to.equal(1); }); it("should find the next available id", function() { - expect(utils.nextId(items)).toEqual(2); + expect(utils.nextId(items)).to.equal(2); }); }); describe("range", function(){ it("should return an array of given lenght", function() { var array = utils.range(5); - expect(array.length).toBe(5); + expect(array.length).to.equal(5); }); it("should return an array where values equal index", function() { var array = utils.range(3); - expect(array).toEqual([0,1,2]); + expect(array).to.eql([0,1,2]); }); }); @@ -36,13 +38,13 @@ describe("permut", function(){ it("should not modify the orinal array", function() { var array = utils.permut(original, 1, 2); - expect(array).not.toEqual(original); + expect(array).not.to.equal(original); }); it("should permut 2 elements in an array", function() { var array = utils.permut(original, 1, 2); - expect(array[1]).toEqual(original[2]); - expect(array[2]).toEqual(original[1]); + expect(array[1]).to.equal(original[2]); + expect(array[2]).to.equal(original[1]); }); }); diff --git a/test/dom.js b/test/dom.js new file mode 100644 index 0000000..372e146 --- /dev/null +++ b/test/dom.js @@ -0,0 +1,7 @@ +var jsdom = require("jsdom"); + +// A super simple DOM ready for React to render into +// Store this DOM and the window in global scope ready for React to access +global.document = jsdom.jsdom(""); +global.window = document.defaultView; +global.navigator = window.navigator; \ No newline at end of file diff --git a/test/mocha.opts b/test/mocha.opts new file mode 100644 index 0000000..70fef4b --- /dev/null +++ b/test/mocha.opts @@ -0,0 +1,3 @@ +--require test/dom.js +--compilers js:babel/register +--reporter spec \ No newline at end of file From 4aec10dc0671eff39b9ad524f389cead88284aae Mon Sep 17 00:00:00 2001 From: Lionel Breduillieard Date: Mon, 14 Sep 2015 17:01:59 +0200 Subject: [PATCH 4/4] add fix from review --- .eslintrc | 36 +++++++--------- gulpfile.js | 41 ++++++++----------- package.json | 2 +- src/js/components/GlyphiconLink.jsx | 2 +- src/js/components/KeptEntry.jsx | 7 ++-- src/js/components/KeptItems.jsx | 2 +- .../__tests__/DefaultContent-test.jsx | 6 +-- src/js/components/__tests__/KeptApp-test.jsx | 5 +-- .../components/__tests__/KeptColumns-test.jsx | 2 +- .../components/__tests__/KeptEntry-test.jsx | 6 +-- .../components/__tests__/KeptItems-test.jsx | 6 +-- src/js/components/text/KeptText.jsx | 2 +- .../text/__tests__/KeptText-test.jsx | 5 ++- .../text/__tests__/KeptTextForm-test.jsx | 19 ++++----- src/js/components/todo/KeptTodoForm.jsx | 2 - src/js/components/todo/KeptTodoTaskForm.jsx | 2 +- .../todo/__tests__/KeepTodo-test.jsx | 10 ++--- src/js/kept.jsx | 2 +- src/js/mixins/__tests__/Resize-test.jsx | 4 +- test/dom.js | 2 +- test/mocha.opts | 2 +- 21 files changed, 73 insertions(+), 92 deletions(-) diff --git a/.eslintrc b/.eslintrc index 4521258..50964de 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,30 +1,22 @@ { "rules": { - "indent": [ - 2, - 2 - ], - "quotes": [ - 2, - "double" - ], - "linebreak-style": [ - 2, - "unix" - ], - "semi": [ - 2, - "always" - ], - "no-console": [ - 1 - ] + "array-bracket-spacing": [2, "never"], + "indent": [2, 2], + "linebreak-style": [2, "unix"], + "no-console": 1, + "object-curly-spacing": [2, "never"], + "quotes": [2, "double", "avoid-escape"], + "semi": [2,"always"], + "space-infix-ops": 2, + // react rules + "react/jsx-quotes": [2, "double"], + "react/jsx-uses-react": 2 }, "env": { "browser": true, - "node": true, - "mocha": true + "mocha": true, + "node": true }, "extends": "eslint:recommended", "ecmaFeatures": { @@ -33,4 +25,4 @@ "plugins": [ "react" ] -} \ No newline at end of file +} diff --git a/gulpfile.js b/gulpfile.js index 73de62b..3d917b5 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,15 +1,13 @@ -/* jshint node:true */ - "use strict"; var gulp = require("gulp"); -var browserify = require('browserify'); -var watchify = require('watchify'); -var source = require('vinyl-source-stream'); -var uglify = require('gulp-uglify'); +var browserify = require("browserify"); +var watchify = require("watchify"); +var source = require("vinyl-source-stream"); +var uglify = require("gulp-uglify"); var deploy = require("gulp-gh-pages"); -var extend = require('util')._extend; +var extend = require("util")._extend; var opt = { outputFolder: "build", @@ -46,7 +44,7 @@ var opt = { }; var jsxOpt = { - extensions: ['.jsx'] + extensions: [".jsx"] }; /** @@ -80,11 +78,11 @@ gulp.task("assets:fonts", function() { gulp.task("js", [ "js:vendors", "js:app" - ]); +]); gulp.task("js:app", ["js:vendors"], function() { return browserify(jsxOpt) - .add("./"+opt.app.src) + .add("./" + opt.app.src) .transform("reactify", {global: true}) .external("react") .external("react-dom") @@ -110,15 +108,10 @@ gulp.task("js:vendors", function() { /** * Server task */ -// gulp.task("server", function() { -// return gulp.src(opt.outputFolder) -// .pipe(webserver(opt.server)); -// }); -// -var connect = require('connect'); -var livereload = require('connect-livereload'); -var staticFile = require('serve-static'); -var lrServer = require('tiny-lr')(); +var connect = require("connect"); +var livereload = require("connect-livereload"); +var staticFile = require("serve-static"); +var lrServer = require("tiny-lr")(); gulp.task("server", function() { @@ -126,7 +119,7 @@ gulp.task("server", function() { .listen(opt.server.livereload); connect() - .use(livereload({ port: opt.server.livereload })) + .use(livereload({port: opt.server.livereload})) .use(staticFile(opt.outputFolder)) .listen(4000); }); @@ -138,7 +131,7 @@ gulp.task("server", function() { gulp.task("watchify", function(){ var args = extend(watchify.args, jsxOpt); - var b = browserify("./"+opt.app.src, args) + var b = browserify("./" + opt.app.src, args) .transform("reactify", {global: true}) .external("react") .external("react-dom") @@ -166,7 +159,7 @@ gulp.task("watch", ["assets","js:vendors", "watchify"], function() { gulp.watch(opt.cssAssets, ["assets:css"]); gulp.watch(opt.fontAssets, ["assets:fonts"]); gulp.watch(opt.htmlAssets, ["assets:html"]); - gulp.watch(opt.outputFolder+"/**/*", function(file){ + gulp.watch(opt.outputFolder + "/**/*", function(file){ lrServer.changed({body : {files : [file.path]}}); }); }); @@ -186,7 +179,7 @@ gulp.task("deploy", ["dist"], function() { }); gulp.task("default", ["server", "watch"], function(done){ - console.log("app running at http://"+opt.server.host+":"+opt.server.port); - require('opn')("http://"+opt.server.host+":"+opt.server.port); + console.log("app running at http://" + opt.server.host + ":" + opt.server.port); + require("opn")("http://" + opt.server.host + ":" + opt.server.port); done(); }); diff --git a/package.json b/package.json index 29ff3e2..0bda5d3 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "deploy": "gulp deploy", "dist": "gulp dist", - "lint": "eslint src", + "lint": "eslint --ext .js --ext .jsx src gulpfile.js", "start": "gulp", "test": "mocha src/**/__tests__/*", "tdd": "mocha --watch ./src/**/__tests__/*.*" diff --git a/src/js/components/GlyphiconLink.jsx b/src/js/components/GlyphiconLink.jsx index 320564e..c0309bf 100644 --- a/src/js/components/GlyphiconLink.jsx +++ b/src/js/components/GlyphiconLink.jsx @@ -7,7 +7,7 @@ var Glyphicon = require("react-bootstrap").Glyphicon; var GlyphiconLink = React.createClass({ render: function() { return ( - + ); } }); diff --git a/src/js/components/KeptEntry.jsx b/src/js/components/KeptEntry.jsx index 1f0c5ba..0d8eaf5 100644 --- a/src/js/components/KeptEntry.jsx +++ b/src/js/components/KeptEntry.jsx @@ -28,8 +28,9 @@ var KeptEntry = React.createClass({ }, handleClickDelete: function() { - if (!confirm("Are you sure?")) - return; + if (!confirm("Are you sure?")) { + return; + } this.refs.wrapper.classList.add("fade"); this.timeout = setTimeout(function() { this.refs.wrapper.classList.remove("fade"); // just don't ask. @@ -39,7 +40,7 @@ var KeptEntry = React.createClass({ handleDragStart: function(event) { event.dataTransfer.effectAllowed = "move"; - event.dataTransfer.setData('text/plain', this.props.itemIndex); + event.dataTransfer.setData("text/plain", this.props.itemIndex); }, handleDragEnter: function(event) { diff --git a/src/js/components/KeptItems.jsx b/src/js/components/KeptItems.jsx index 5d1cc98..b46c35a 100644 --- a/src/js/components/KeptItems.jsx +++ b/src/js/components/KeptItems.jsx @@ -40,7 +40,7 @@ var KeepItems = React.createClass({ .range(this.state.columns) .map(function(_, index) { var colItems = this.props.items.filter(function(item, i) { - return i%this.state.columns === index; + return i % this.state.columns === index; }, this); return ( diff --git a/src/js/components/__tests__/DefaultContent-test.jsx b/src/js/components/__tests__/DefaultContent-test.jsx index 113ad00..29e40d9 100644 --- a/src/js/components/__tests__/DefaultContent-test.jsx +++ b/src/js/components/__tests__/DefaultContent-test.jsx @@ -18,7 +18,7 @@ describe("DefaultContent", function() { }); it("should render HTML content", function() { - expect(result.props.children.length > 0).to.be.true; + expect(result.props.children.length > 0).eql(true); }); }); @@ -43,7 +43,7 @@ describe("DefaultContent", function() { TestUtils.Simulate.click(newTextLink); - expect(fakeCreateText.calledOnce).to.be.true; + expect(fakeCreateText.calledOnce).eql(true); }); it("should add a new todo entry when clicking on Todo link", function() { @@ -51,7 +51,7 @@ describe("DefaultContent", function() { TestUtils.Simulate.click(newTodoLink); - expect(fakeCreateTodo.calledOnce).to.be.true; + expect(fakeCreateTodo.calledOnce).eql(true); }); }); }); diff --git a/src/js/components/__tests__/KeptApp-test.jsx b/src/js/components/__tests__/KeptApp-test.jsx index a8aed1d..c41c37e 100644 --- a/src/js/components/__tests__/KeptApp-test.jsx +++ b/src/js/components/__tests__/KeptApp-test.jsx @@ -4,7 +4,6 @@ var TestUtils = require("react/lib/ReactTestUtils"); var React = require("react"); var expect = require("chai").expect; var renderer = TestUtils.createRenderer(); - var KeptApp = require("../KeptApp"); var KeptTextForm = require("../text/KeptTextForm"); var KeptTodoForm = require("../todo/KeptTodoForm"); @@ -49,7 +48,7 @@ describe("KeptApp", function() { textForm({}); - //expect(TestUtils.isComponentOfType(comp.state.form, KeptTextForm)).to.be.true; + expect(TestUtils.isElementOfType (comp.state.form, KeptTextForm)).eql(true); }); it("should add a todo form component to state", function() { @@ -57,7 +56,7 @@ describe("KeptApp", function() { todoForm({}); - //expect(TestUtils.isComponentOfType(comp.state.form, KeptTodoForm)).to.be.true; + expect(TestUtils.isElementOfType (comp.state.form, KeptTodoForm)).eql(true); }); }); }); diff --git a/src/js/components/__tests__/KeptColumns-test.jsx b/src/js/components/__tests__/KeptColumns-test.jsx index 2139d06..66fae7e 100644 --- a/src/js/components/__tests__/KeptColumns-test.jsx +++ b/src/js/components/__tests__/KeptColumns-test.jsx @@ -22,7 +22,7 @@ describe("KeptColumns", function() { var comp = TestUtils.renderIntoDocument(); var entries = TestUtils.scryRenderedComponentsWithType(comp, KeptEntry); - expect(entries.length).to.equal(3); + expect(entries.length).to.eql(3); }); }); }); diff --git a/src/js/components/__tests__/KeptEntry-test.jsx b/src/js/components/__tests__/KeptEntry-test.jsx index 8c0c916..87eb18e 100644 --- a/src/js/components/__tests__/KeptEntry-test.jsx +++ b/src/js/components/__tests__/KeptEntry-test.jsx @@ -46,7 +46,7 @@ describe("KeptEntry", function() { id: 42, title: "test text", text: "text" - })).to.be.true; + })).to.eql(true); }); }); @@ -59,7 +59,7 @@ describe("KeptEntry", function() { text: "text" }}); - expect(TestUtils.findRenderedComponentWithType(comp, KeptText)).to.be.ok; + expect(TestUtils.findRenderedComponentWithType(comp, KeptText)).to.not.eql(null); }); it("should render a todo entry", function() { @@ -74,7 +74,7 @@ describe("KeptEntry", function() { update: fakeUpdate }); - expect(TestUtils.findRenderedComponentWithType(comp, KeptTodo)).to.be.ok; + expect(TestUtils.findRenderedComponentWithType(comp, KeptTodo)).to.not.eql(null); }); }); }); diff --git a/src/js/components/__tests__/KeptItems-test.jsx b/src/js/components/__tests__/KeptItems-test.jsx index 9bc8d29..6c30aab 100644 --- a/src/js/components/__tests__/KeptItems-test.jsx +++ b/src/js/components/__tests__/KeptItems-test.jsx @@ -8,8 +8,6 @@ var sinon = require("sinon"); var KeptItems = require("../KeptItems"); var DefaultContent = require("../DefaultContent"); var KeptColumns = require("../KeptColumns"); -var range = require('../../utils').range; - describe("KeptItems", function() { describe("#render", function() { @@ -35,14 +33,14 @@ describe("KeptItems", function() { {id: 2, type: "text", text: "text id #2"}, {id: 3, type: "text", text: "text id #3"}, {id: 4, type: "text", text: "text id #3"}, - {id: 5, type: "text", text: "text id #3"}, + {id: 5, type: "text", text: "text id #3"} ]; var comp = TestUtils.renderIntoDocument(); var entries = TestUtils.scryRenderedComponentsWithType(comp, KeptColumns); - expect(entries.length).to.equal(array.length); + expect(entries).to.have.length.of(array.length); }); }); }); diff --git a/src/js/components/text/KeptText.jsx b/src/js/components/text/KeptText.jsx index 5ee7680..22b560e 100644 --- a/src/js/components/text/KeptText.jsx +++ b/src/js/components/text/KeptText.jsx @@ -18,7 +18,7 @@ var KeptText = React.createClass({ render: function() { return (
    -
    ); diff --git a/src/js/components/text/__tests__/KeptText-test.jsx b/src/js/components/text/__tests__/KeptText-test.jsx index d6d1627..c7715a0 100644 --- a/src/js/components/text/__tests__/KeptText-test.jsx +++ b/src/js/components/text/__tests__/KeptText-test.jsx @@ -1,10 +1,11 @@ "use strict"; var React = require("react"); +var reactDom = require("react-dom"); var TestUtils = require("react/lib/ReactTestUtils"); var expect = require("chai").expect; -var KeptText = require('../KeptText'); +var KeptText = require("../KeptText"); describe("KeptText", function(){ describe("#render", function() { var comp; @@ -15,7 +16,7 @@ describe("KeptText", function(){ }); it("should render markdown text as HTML", function() { - expect(comp.refs.content.querySelector("h1").textContent).to.equal("plop"); + expect(reactDom.findDOMNode(comp).querySelector("h1").textContent).to.eql("plop"); }); }); }); diff --git a/src/js/components/text/__tests__/KeptTextForm-test.jsx b/src/js/components/text/__tests__/KeptTextForm-test.jsx index f29a966..aa9f92f 100644 --- a/src/js/components/text/__tests__/KeptTextForm-test.jsx +++ b/src/js/components/text/__tests__/KeptTextForm-test.jsx @@ -42,36 +42,35 @@ describe("KeptTextForm", function() { type: "text", title: "Hello", text: "# world" - })).to.be.true; + })).to.eql(true); }); it("should update an existing text", function() { var comp = TestUtils.renderIntoDocument( ); - TestUtils.Simulate.change(reactDom.findDOMNode(comp.refs.title) , + TestUtils.Simulate.change(comp.refs.title , {target: {value: "Plip"}}); - TestUtils.Simulate.change(reactDom.findDOMNode(comp.refs.text), + TestUtils.Simulate.change(comp.refs.text, {target: {value: "# plip"}}); - TestUtils.Simulate.submit(reactDom.findDOMNode(comp.refs.title).form); + TestUtils.Simulate.submit(comp.refs.title.form); expect(fakeUpdate.calledWith({ id: 1, type: "text", title: "Plip", text: "# plip" - })).to.be.true; + })).to.eql(true); }); }); describe("#render", function() { it("should render HTML content", function() { - var renderer = TestUtils.createRenderer(); - renderer.render(); - - var result = renderer.getRenderOutput(); + var comp = TestUtils.renderIntoDocument( + + ); - expect(result.props.children.length).to.equal(3); + expect(reactDom.findDOMNode(comp).querySelector("form")).to.not.eql(null); }); }); }); diff --git a/src/js/components/todo/KeptTodoForm.jsx b/src/js/components/todo/KeptTodoForm.jsx index bf70ac2..b6d6b06 100644 --- a/src/js/components/todo/KeptTodoForm.jsx +++ b/src/js/components/todo/KeptTodoForm.jsx @@ -1,7 +1,6 @@ "use strict"; var React = require("react"); -var reactDom = require("react-dom"); var Modal = require("react-bootstrap").Modal; var KeptTodoTaskForm = require("./KeptTodoTaskForm"); @@ -42,7 +41,6 @@ var KeptTodoForm = React.createClass({ id: id, title: this.refs.title.value.trim(), tasks: (this.state.tasks || []).filter(function(task) { - console.log(task.label) return !!task.label; }) }); diff --git a/src/js/components/todo/KeptTodoTaskForm.jsx b/src/js/components/todo/KeptTodoTaskForm.jsx index 0bd1b22..d24aa3b 100644 --- a/src/js/components/todo/KeptTodoTaskForm.jsx +++ b/src/js/components/todo/KeptTodoTaskForm.jsx @@ -3,7 +3,7 @@ var React = require("react"); var KeptTodoTaskForm = React.createClass({ - handleUpdate: function(event) { + handleUpdate: function() { this.props.updateTask(this.props.index, { label: this.refs.label.value.trim(), done: this.refs.done.checked diff --git a/src/js/components/todo/__tests__/KeepTodo-test.jsx b/src/js/components/todo/__tests__/KeepTodo-test.jsx index 5c67e89..1ef1277 100644 --- a/src/js/components/todo/__tests__/KeepTodo-test.jsx +++ b/src/js/components/todo/__tests__/KeepTodo-test.jsx @@ -11,7 +11,7 @@ describe("KeptTodo", function() { var comp, fakeUpdate; function renderWithProps(props) { - return TestUtils.renderIntoDocument( ); + return TestUtils.renderIntoDocument(); } beforeEach(function() { @@ -37,7 +37,7 @@ describe("KeptTodo", function() { describe("#getProgress", function() { it("should compute task completion percentage", function() { - expect(comp.getDOMNode().querySelector('[aria-valuenow="33"]')).to.be.ok; + expect(comp.getDOMNode().querySelector('[aria-valuenow="33"]')).to.not.eql(null); }); }); @@ -56,7 +56,7 @@ describe("KeptTodo", function() { {label: "todo2", done: false}, {label: "todo3", done: false} ] - })).to.be.true; + })).to.eql(true); }); }); @@ -74,13 +74,13 @@ describe("KeptTodo", function() { {label: "todo1", done: false}, {label: "todo3", done: false} ] - })).to.be.true; + })).to.eql(true); }); }); describe("#render", function() { it("should render expected amount of entries", function() { - expect(comp.refs.taskItems.querySelectorAll(".list-group-item").length).to.equal(3); + expect(comp.refs.taskItems.querySelectorAll(".list-group-item").length).to.eql(3); }); }); }); diff --git a/src/js/kept.jsx b/src/js/kept.jsx index 88facd0..97879ce 100644 --- a/src/js/kept.jsx +++ b/src/js/kept.jsx @@ -7,4 +7,4 @@ var KeptStore = require("./store"); var store = new KeptStore(); reactDom.render(, - document.getElementById('kept')); + document.getElementById("kept")); diff --git a/src/js/mixins/__tests__/Resize-test.jsx b/src/js/mixins/__tests__/Resize-test.jsx index 402584d..598d7ad 100644 --- a/src/js/mixins/__tests__/Resize-test.jsx +++ b/src/js/mixins/__tests__/Resize-test.jsx @@ -32,6 +32,6 @@ describe("Columns", function(){ }); it("should have a state columns", function(){ - expect(compo.state.columns).to.equal(3); + expect(compo.state.columns).to.eql(3); }); -}); \ No newline at end of file +}); diff --git a/test/dom.js b/test/dom.js index 372e146..3334888 100644 --- a/test/dom.js +++ b/test/dom.js @@ -4,4 +4,4 @@ var jsdom = require("jsdom"); // Store this DOM and the window in global scope ready for React to access global.document = jsdom.jsdom(""); global.window = document.defaultView; -global.navigator = window.navigator; \ No newline at end of file +global.navigator = window.navigator; diff --git a/test/mocha.opts b/test/mocha.opts index 70fef4b..be8c57d 100644 --- a/test/mocha.opts +++ b/test/mocha.opts @@ -1,3 +1,3 @@ --require test/dom.js --compilers js:babel/register ---reporter spec \ No newline at end of file +--reporter spec