From 080702ac872f848b347ab6d311e078760fd77959 Mon Sep 17 00:00:00 2001 From: Bartvds Date: Sat, 8 Jun 2013 18:16:44 +0200 Subject: [PATCH 1/2] added assert.notOk() --- lib/chai/interface/assert.js | 18 ++++++++++++++++++ test/assert.js | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/lib/chai/interface/assert.js b/lib/chai/interface/assert.js index 6760a7ebe..ed942ccf8 100644 --- a/lib/chai/interface/assert.js +++ b/lib/chai/interface/assert.js @@ -82,6 +82,24 @@ module.exports = function (chai, util) { new Assertion(val, msg).is.ok; }; + /** + * ### .notOk(object, [message]) + * + * Asserts that `object` is falsy. + * + * assert.notOk('everything', 'this will fail'); + * assert.notOk(false, 'this will pass'); + * + * @name notOk + * @param {Mixed} object to test + * @param {String} message + * @api public + */ + + assert.notOk = function (val, msg) { + new Assertion(val, msg).is.not.ok; + }; + /** * ### .equal(actual, expected, [message]) * diff --git a/test/assert.js b/test/assert.js index 551b0ecff..4d6c0b5b2 100644 --- a/test/assert.js +++ b/test/assert.js @@ -50,6 +50,24 @@ suite('assert', function () { }, "expected '' to be truthy"); }); + test('notOk', function () { + assert.notOk(false); + assert.notOk(0); + assert.notOk(''); + + err(function () { + assert.notOk(true); + }, "expected true to be falsy"); + + err(function () { + assert.notOk(1); + }, "expected 1 to be falsy"); + + err(function () { + assert.notOk('test'); + }, "expected 'test' to be falsy"); + }); + test('isFalse', function () { assert.isFalse(false); From 774a723bff474d890d46b396e09941d36303e6c2 Mon Sep 17 00:00:00 2001 From: Bartvds Date: Sun, 9 Jun 2013 01:27:05 +0200 Subject: [PATCH 2/2] replaced tabs with 2 spaces --- lib/chai/interface/assert.js | 2 +- test/assert.js | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/chai/interface/assert.js b/lib/chai/interface/assert.js index ed942ccf8..fe9f31711 100644 --- a/lib/chai/interface/assert.js +++ b/lib/chai/interface/assert.js @@ -97,7 +97,7 @@ module.exports = function (chai, util) { */ assert.notOk = function (val, msg) { - new Assertion(val, msg).is.not.ok; + new Assertion(val, msg).is.not.ok; }; /** diff --git a/test/assert.js b/test/assert.js index 4d6c0b5b2..ffb458808 100644 --- a/test/assert.js +++ b/test/assert.js @@ -51,21 +51,21 @@ suite('assert', function () { }); test('notOk', function () { - assert.notOk(false); - assert.notOk(0); - assert.notOk(''); + assert.notOk(false); + assert.notOk(0); + assert.notOk(''); - err(function () { - assert.notOk(true); - }, "expected true to be falsy"); + err(function () { + assert.notOk(true); + }, "expected true to be falsy"); - err(function () { - assert.notOk(1); - }, "expected 1 to be falsy"); + err(function () { + assert.notOk(1); + }, "expected 1 to be falsy"); - err(function () { - assert.notOk('test'); - }, "expected 'test' to be falsy"); + err(function () { + assert.notOk('test'); + }, "expected 'test' to be falsy"); }); test('isFalse', function () {