From 5223164cb9612fd0c9a385995461a36b4ebc41ea Mon Sep 17 00:00:00 2001 From: lucasfcosta Date: Sun, 20 Mar 2016 16:07:02 -0300 Subject: [PATCH] Simplify adding language chains with a check for the getter argument --- lib/chai/core/assertions.js | 2 ++ lib/chai/utils/addProperty.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lib/chai/core/assertions.js b/lib/chai/core/assertions.js index 68f8c277b..1c03fef12 100644 --- a/lib/chai/core/assertions.js +++ b/lib/chai/core/assertions.js @@ -44,6 +44,8 @@ module.exports = function (chai, _) { , 'with', 'that', 'which', 'at' , 'of', 'same', 'but' ].forEach(function (chain) { Assertion.addProperty(chain, function () { + var newAssertion = new Assertion(); + _.transferFlags(this, newAssertion); return this; }); }); diff --git a/lib/chai/utils/addProperty.js b/lib/chai/utils/addProperty.js index fd3b732ca..64e69ba32 100644 --- a/lib/chai/utils/addProperty.js +++ b/lib/chai/utils/addProperty.js @@ -35,6 +35,8 @@ var transferFlags = require('./transferFlags'); */ module.exports = function (ctx, name, getter) { + getter = getter === undefined ? new Function() : getter; + Object.defineProperty(ctx, name, { get: function addProperty() { var old_ssfi = flag(this, 'ssfi');