Skip to content

Commit

Permalink
Fix todo title getting undefined after edit
Browse files Browse the repository at this point in the history
Closes cyclejs#39
  • Loading branch information
hgwood committed Aug 7, 2017
1 parent 7b2536c commit 5a96c67
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"live-server": "^0.9.0",
"mkdirp": "^0.5.1",
"npm-run-all": "^1.4.0",
"tape": "^4.8.0",
"uglify-js": "2.6.1",
"watchify": "^3.6.1"
},
Expand All @@ -47,6 +48,7 @@
"serve": "live-server ./",
"uglify": "uglifyjs js/app.js -o js/app.min.js",
"build": "npm run build-debug && npm run uglify",
"start": "npm-run-all --parallel watch:js serve"
"start": "npm-run-all --parallel watch:js serve",
"test": "tape -r babel-register **/*.test.js"
}
}
4 changes: 2 additions & 2 deletions src/components/Task/model.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import xs from 'xstream';

function makeReducer$(action$) {
export function makeReducer$(action$) {
let startEditReducer$ = action$
.filter(action => action.type === 'startEdit')
.mapTo(function startEditReducer(data) {
Expand All @@ -15,7 +15,7 @@ function makeReducer$(action$) {
.map(action => function doneEditReducer(data) {
return {
...data,
title: action.payload,
title: action.title,
editing: false
};
});
Expand Down
20 changes: 20 additions & 0 deletions src/components/Task/model.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import test from 'tape';
import {makeReducer$} from './model';
import xs from 'xstream';

test('doneEdit updates the title of the todo', assert => {
const expected = 'newTitle';
makeReducer$(xs.fromArray([{type: 'doneEdit', title: expected}]))
.addListener({
next(reducer) {
const actual = reducer({}).title
assert.deepEqual(actual, expected)
},
error(err) {
throw err;
},
complete() {
assert.end()
}
})
})

0 comments on commit 5a96c67

Please sign in to comment.