From b826feba514a6caa1f2fa5103e6e16a310a1a7bb Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Thu, 13 Nov 2014 11:58:50 +0000 Subject: [PATCH] Revert "Allows writing lint-friendly tests" --- lib/chai/assertion.js | 5 ---- lib/chai/core/assertions.js | 52 +++++++------------------------------ test/expect.js | 32 ----------------------- 3 files changed, 9 insertions(+), 80 deletions(-) diff --git a/lib/chai/assertion.js b/lib/chai/assertion.js index dcded9e80..a3405a832 100644 --- a/lib/chai/assertion.js +++ b/lib/chai/assertion.js @@ -6,7 +6,6 @@ */ var config = require('./config'); -var NOOP = function() { }; module.exports = function (_chai, util) { /*! @@ -70,10 +69,6 @@ module.exports = function (_chai, util) { util.addChainableMethod(this.prototype, name, fn, chainingBehavior); }; - Assertion.addChainableNoop = function(name, fn) { - util.addChainableMethod(this.prototype, name, NOOP, fn); - }; - Assertion.overwriteProperty = function (name, fn) { util.overwriteProperty(this.prototype, name, fn); }; diff --git a/lib/chai/core/assertions.js b/lib/chai/core/assertions.js index 875603df4..97a85d124 100644 --- a/lib/chai/core/assertions.js +++ b/lib/chai/core/assertions.js @@ -186,15 +186,11 @@ module.exports = function (chai, _) { * expect(undefined).to.not.be.ok; * expect(null).to.not.be.ok; * - * Can also be used as a function, which prevents some linter errors. - * - * expect('everthing').to.be.ok(); - * * @name ok * @api public */ - Assertion.addChainableNoop('ok', function () { + Assertion.addProperty('ok', function () { this.assert( flag(this, 'object') , 'expected #{this} to be truthy' @@ -209,15 +205,11 @@ module.exports = function (chai, _) { * expect(true).to.be.true; * expect(1).to.not.be.true; * - * Can also be used as a function, which prevents some linter errors. - * - * expect(true).to.be.true(); - * * @name true * @api public */ - Assertion.addChainableNoop('true', function () { + Assertion.addProperty('true', function () { this.assert( true === flag(this, 'object') , 'expected #{this} to be true' @@ -234,15 +226,11 @@ module.exports = function (chai, _) { * expect(false).to.be.false; * expect(0).to.not.be.false; * - * Can also be used as a function, which prevents some linter errors. - * - * expect(false).to.be.false(); - * * @name false * @api public */ - Assertion.addChainableNoop('false', function () { + Assertion.addProperty('false', function () { this.assert( false === flag(this, 'object') , 'expected #{this} to be false' @@ -259,15 +247,11 @@ module.exports = function (chai, _) { * expect(null).to.be.null; * expect(undefined).not.to.be.null; * - * Can also be used as a function, which prevents some linter errors. - * - * expect(null).to.be.null(); - * * @name null * @api public */ - Assertion.addChainableNoop('null', function () { + Assertion.addProperty('null', function () { this.assert( null === flag(this, 'object') , 'expected #{this} to be null' @@ -283,15 +267,11 @@ module.exports = function (chai, _) { * expect(undefined).to.be.undefined; * expect(null).to.not.be.undefined; * - * Can also be used as a function, which prevents some linter errors. - * - * expect(undefined).to.be.undefined(); - * * @name undefined * @api public */ - Assertion.addChainableNoop('undefined', function () { + Assertion.addProperty('undefined', function () { this.assert( undefined === flag(this, 'object') , 'expected #{this} to be undefined' @@ -312,15 +292,11 @@ module.exports = function (chai, _) { * expect(bar).to.not.exist; * expect(baz).to.not.exist; * - * Can also be used as a function, which prevents some linter errors. - * - * expect(foo).to.exist(); - * * @name exist * @api public */ - Assertion.addChainableNoop('exist', function () { + Assertion.addProperty('exist', function () { this.assert( null != flag(this, 'object') , 'expected #{this} to exist' @@ -340,15 +316,11 @@ module.exports = function (chai, _) { * expect('').to.be.empty; * expect({}).to.be.empty; * - * Can also be used as a function, which prevents some linter errors. - * - * expect([]).to.be.empty(); - * * @name empty * @api public */ - Assertion.addChainableNoop('empty', function () { + Assertion.addProperty('empty', function () { var obj = flag(this, 'object') , expected = obj; @@ -374,12 +346,6 @@ module.exports = function (chai, _) { * expect(arguments).to.be.arguments; * } * - * Can also be used as a function, which prevents some linter errors. - * - * function test () { - * expect(arguments).to.be.arguments(); - * } - * * @name arguments * @alias Arguments * @api public @@ -395,8 +361,8 @@ module.exports = function (chai, _) { ); } - Assertion.addChainableNoop('arguments', checkArguments); - Assertion.addChainableNoop('Arguments', checkArguments); + Assertion.addProperty('arguments', checkArguments); + Assertion.addProperty('Arguments', checkArguments); /** * ### .equal(value) diff --git a/test/expect.js b/test/expect.js index 905e2bd8d..bd03a50c9 100644 --- a/test/expect.js +++ b/test/expect.js @@ -15,10 +15,6 @@ describe('expect', function () { expect(false).to.not.be.true; expect(1).to.not.be.true; - expect(true).to.be.true(); - expect(true).to.be.true().and.not.false; - expect(true).to.be.true.and.not.false(); - err(function(){ expect('test').to.be.true; }, "expected 'test' to be true") @@ -30,10 +26,6 @@ describe('expect', function () { expect(1).to.be.ok; expect(0).to.not.be.ok; - expect(true).to.be.ok(); - expect(true).to.be.ok().and.not.false; - expect(true).to.be.ok.and.not.false(); - err(function(){ expect('').to.be.ok; }, "expected '' to be truthy"); @@ -48,10 +40,6 @@ describe('expect', function () { expect(true).to.not.be.false; expect(0).to.not.be.false; - expect(false).to.be.false(); - expect(false).to.be.false().and.not.true; - expect(false).to.be.false.and.not.true(); - err(function(){ expect('').to.be.false; }, "expected '' to be false") @@ -61,10 +49,6 @@ describe('expect', function () { expect(null).to.be.null; expect(false).to.not.be.null; - expect(null).to.be.null(); - expect(null).to.be.null().and.not.ok(); - expect(null).to.be.null.and.not.ok(); - err(function(){ expect('').to.be.null; }, "expected '' to be null") @@ -75,10 +59,6 @@ describe('expect', function () { expect(undefined).to.be.undefined; expect(null).to.not.be.undefined; - expect(undefined).to.be.undefined(); - expect(undefined).to.be.undefined().and.not.ok(); - expect(undefined).to.be.undefined.and.not.ok(); - err(function(){ expect('').to.be.undefined; }, "expected '' to be undefined") @@ -89,10 +69,6 @@ describe('expect', function () { , bar; expect(foo).to.exist; expect(bar).to.not.exist; - - expect(foo).to.exist(); - expect(foo).to.exist().and.contain('bar'); - expect(foo).to.exist.and.contain('bar'); }); it('arguments', function(){ @@ -101,10 +77,6 @@ describe('expect', function () { expect([]).to.not.be.arguments; expect(args).to.be.an('arguments').and.be.arguments; expect([]).to.be.an('array').and.not.be.Arguments; - - expect(args).to.be.Arguments(); - expect(args).to.be.arguments().and.be.ok; - expect(args).to.be.arguments.and.be.ok(); }); it('.equal()', function(){ @@ -383,10 +355,6 @@ describe('expect', function () { expect({}).to.be.empty; expect({foo: 'bar'}).not.to.be.empty; - expect('').to.be.empty(); - expect('').to.be.empty().and.exist; - expect('').to.be.empty.and.exist; - err(function(){ expect('').not.to.be.empty; }, "expected \'\' not to be empty");