From c6fa04dd2c37cbb5d4f51f0f998b4670b7bdbd1a Mon Sep 17 00:00:00 2001 From: Liu Yang Date: Mon, 20 Apr 2015 15:57:15 +0800 Subject: [PATCH] detect jquery object with both instanceof and jquery attribute --- chai-jquery.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/chai-jquery.js b/chai-jquery.js index 819a27d..e46ec66 100644 --- a/chai-jquery.js +++ b/chai-jquery.js @@ -166,7 +166,7 @@ chai.Assertion.overwriteProperty('exist', function (_super) { return function () { var obj = flag(this, 'object'); - if (obj instanceof $) { + if (obj instanceof $ || obj.jquery) { this.assert( obj.length > 0 , 'expected ' + inspect(obj.selector) + ' to exist' @@ -180,7 +180,7 @@ chai.Assertion.overwriteProperty('empty', function (_super) { return function () { var obj = flag(this, 'object'); - if (obj instanceof $) { + if (obj instanceof $ || obj.jquery) { this.assert( obj.is(':empty') , 'expected #{this} to be empty' @@ -194,7 +194,7 @@ chai.Assertion.overwriteMethod('match', function (_super) { return function (selector) { var obj = flag(this, 'object'); - if (obj instanceof $) { + if (obj instanceof $ || obj.jquery) { this.assert( obj.is(selector) , 'expected #{this} to match #{exp}' @@ -211,7 +211,7 @@ function (_super) { return function (text) { var obj = flag(this, 'object'); - if (obj instanceof $) { + if (obj instanceof $ || obj.jquery) { this.assert( obj.is(':contains(\'' + text + '\')') , 'expected #{this} to contain #{exp}'