diff --git a/lib/if.js b/lib/if.js index 1e9ed2d..d8b1eac 100644 --- a/lib/if.js +++ b/lib/if.js @@ -2,5 +2,5 @@ import ifElse from './ifElse'; import curry from './util/curry'; export default curry((predicate, trueUpdates, object) => - ifElse(predicate, trueUpdates, {}, object) + ifElse(predicate, trueUpdates, x => x, object) ); diff --git a/package.json b/package.json index 35c605e..683f88d 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ ], "scripts": { "test": "gulp", + "test:watch": "gulp watch", "prepublish": "gulp prepublish", "perf-server": "`npm bin`/webpack-dev-server --config perf/webpack.config.js --hot" }, diff --git a/test/if-spec.js b/test/if-spec.js index 399383f..7f7f485 100644 --- a/test/if-spec.js +++ b/test/if-spec.js @@ -4,8 +4,11 @@ import u from '../lib'; describe('u.if', () => { it('does not update if the predicate is false', () => { const object = { a: 0 }; - const result = u.if(false, { b: 1 }, object); + let result = u.if(false, { b: 1 }, object); expect(result).to.eql(object); + + result = u({ x: u.if(false, 1)}, {}); + expect(result).to.eql({}); }); it('does update if the predicate is true', () => {