From 051fd95d88cbf7b967ac819e2cc482ce9fc3837f Mon Sep 17 00:00:00 2001 From: Chris Polis Date: Tue, 30 Dec 2014 12:26:19 -0800 Subject: [PATCH] cleaned out `.by` for #333 --- lib/chai/core/assertions.js | 29 ++--------------------------- test/assert.js | 2 -- test/expect.js | 3 --- test/should.js | 4 ---- 4 files changed, 2 insertions(+), 36 deletions(-) diff --git a/lib/chai/core/assertions.js b/lib/chai/core/assertions.js index 2dc52a37e..a5699c659 100644 --- a/lib/chai/core/assertions.js +++ b/lib/chai/core/assertions.js @@ -1429,15 +1429,10 @@ module.exports = function (chai, _) { var fn = flag(this, 'object'); new Assertion(object, msg).to.have.property(prop); new Assertion(fn).is.a('function'); - flag(this, 'property', prop); var initial = object[prop]; fn(); - if ('number' == typeof initial) { - flag(this, 'delta', object[prop] - initial); - } - this.assert( initial !== object[prop] , 'expected .' + prop + ' to change' @@ -1475,12 +1470,9 @@ module.exports = function (chai, _) { var initial = object[prop]; fn(); - var delta = object[prop] - initial; - flag(this, 'delta', delta); - flag(this, 'property', prop); this.assert( - delta > 0 + object[prop] - initial > 0 , 'expected .' + prop + ' to increase' , 'expected .' + prop + ' to not increase' ); @@ -1516,12 +1508,9 @@ module.exports = function (chai, _) { var initial = object[prop]; fn(); - var delta = object[prop] - initial; - flag(this, 'delta', -delta); - flag(this, 'property', prop); this.assert( - delta < 0 + object[prop] - initial < 0 , 'expected .' + prop + ' to decrease' , 'expected .' + prop + ' to not decrease' ); @@ -1530,18 +1519,4 @@ module.exports = function (chai, _) { Assertion.addChainableMethod('decrease', assertDecreases); Assertion.addChainableMethod('decreases', assertDecreases); - function assertChangesBy (expected, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object'), - prop = flag(this, 'property'), - delta = flag(this, 'delta'); - - this.assert( - delta === expected - , 'expected .' + prop + ' to change by ' + expected - , 'expected .' + prop + ' to not change by ' + expected - ); - } - - Assertion.addMethod('by', assertChangesBy); }; diff --git a/test/assert.js b/test/assert.js index e657fd52d..1445ccb35 100644 --- a/test/assert.js +++ b/test/assert.js @@ -707,11 +707,9 @@ describe('assert', function () { smFn = function() { obj.value += 0 }; assert.decreases(decFn, obj, 'value'); - assert.decreasesBy(decFn, obj, 'value', 3); assert.doesNotDecrease(smFn, obj, 'value'); assert.increases(incFn, obj, 'value'); - assert.increasesBy(incFn, obj, 'value', 2); assert.doesNotIncrease(smFn, obj, 'value'); }); diff --git a/test/expect.js b/test/expect.js index beff66aca..df0cabc0d 100644 --- a/test/expect.js +++ b/test/expect.js @@ -907,7 +907,6 @@ describe('expect', function () { bangFn = function() { obj.str += '!' }; expect(fn).to.change(obj, 'value'); - expect(fn).to.change(obj, 'value').by(5); expect(sameFn).to.not.change(obj, 'value'); expect(sameFn).to.not.change(obj, 'str'); expect(bangFn).to.change(obj, 'str'); @@ -922,12 +921,10 @@ describe('expect', function () { expect(smFn).to.not.increase(obj, 'value'); expect(decFn).to.not.increase(obj, 'value'); expect(incFn).to.increase(obj, 'value'); - expect(incFn).to.increase(obj, 'value').by(2); expect(smFn).to.not.decrease(obj, 'value'); expect(incFn).to.not.decrease(obj, 'value'); expect(decFn).to.decrease(obj, 'value'); - expect(decFn).to.decrease(obj, 'value').by(3); }); diff --git a/test/should.js b/test/should.js index 150bc9c8d..c122a01a6 100644 --- a/test/should.js +++ b/test/should.js @@ -787,8 +787,6 @@ describe('should', function() { bangFn = function() { obj.str += '!' }; fn.should.change(obj, 'value'); - fn.should.change(obj, 'value').by(5); - decFn.should.change(obj, 'value').by(-3); sameFn.should.not.change(obj, 'value'); sameFn.should.not.change(obj, 'str'); bangFn.should.change(obj, 'str'); @@ -803,11 +801,9 @@ describe('should', function() { smFn.should.not.increase(obj, 'value'); decFn.should.not.increase(obj, 'value'); incFn.should.increase(obj, 'value'); - incFn.should.increase(obj, 'value').by(2); smFn.should.not.decrease(obj, 'value'); incFn.should.not.decrease(obj, 'value'); decFn.should.decrease(obj, 'value'); - decFn.should.decrease(obj, 'value').by(3); }); });