Skip to content

Commit

Permalink
Simplify adding language chains with a check for the getter argument
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfcosta committed Mar 20, 2016
1 parent 56f6b50 commit 5223164
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/chai/core/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
});
Expand Down
2 changes: 2 additions & 0 deletions lib/chai/utils/addProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 5223164

Please sign in to comment.