diff --git a/History.md b/History.md index 1b3a898..b9848db 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +3.1.2 / 2014-01-28 +================== + + * Fix for adding .inspect for JQuery object only in case when it is exist + 3.1.1 / 2014-01-28 ================== diff --git a/package.json b/package.json index f6bf976..263cf8d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "should" , "description": "test framework agnostic BDD-style assertions" - , "version": "3.1.1" + , "version": "3.1.2" , "author": "TJ Holowaychuk " , "repository": { "type": "git", "url": "git://github.com/visionmedia/should.js.git" } , "homepage": "https://github.com/visionmedia/should.js" diff --git a/should.min.js b/should.min.js index 5398768..5665c29 100644 --- a/should.min.js +++ b/should.min.js @@ -4,51 +4,52 @@ k[f][1][b];return l(c?c:b)},e,e.exports,h,k,d,g)}return d[f].exports}for(var a=" c.global&&f.multiline===c.multiline&&f.lastIndex===c.lastIndex&&f.ignoreCase===c.ignoreCase:a.isObject(f)||a.isObject(c)?l(f,c):f==c}function l(f,c){if(a.isNullOrUndefined(f)||a.isNullOrUndefined(c)||f.prototype!==c.prototype)return!1;if(a.isArguments(f)){if(!a.isArguments(c))return!1;f=e.call(f);c=e.call(c);return g(f,c)}try{var m=Object.keys(f),b=Object.keys(c),p}catch(d){return!1}if(m.length!=b.length)return!1;m.sort();b.sort();for(p=m.length-1;0<=p;p--)if(m[p]!=b[p])return!1;for(p=m.length-1;0<= p;p--)if(b=m[p],!g(f[b],c[b]))return!1;return!0}var a=h("./util");k.exports=g;var e=Array.prototype.slice},{"./util":16}],3:[function(h,k,d){var g=h("../util"),l=h("assert"),a=l.AssertionError;k.exports=function(e){var f=e.format;g.merge(e,l);e.exist=e.exists=function(c,g){if(null==c)throw new a({message:g||"expected "+f(c)+" to exist",stackStartFunction:e.exist});};e.not={};e.not.exist=e.not.exists=function(c,g){if(null!=c)throw new a({message:g||"expected "+f(c)+" to not exist",stackStartFunction:e.not.exist}); }}},{"../util":16,assert:17}],4:[function(h,k,d){k.exports=function(g,d){d.add("true",function(){this.is.exactly(!0)},!0);d.add("false",function(){this.is.exactly(!1)},!0);d.add("ok",function(){this.params={operator:"to be truthy"};this.assert(this.obj)},!0)}},{}],5:[function(h,k,d){var g=h("../../util");k.exports=function(d,a){function e(b,a,e,d,m){var h=(g.isObject(d)?Object.keys(d):[d]).reduce(function(a,r){var f=c(this.obj)[b](r);"undefined"!==typeof f&&(a[r]=f);return a}.bind(this),{});4===arguments.length&& -g.isObject(d)?(this.params={operator:"to have "+e+" "+f(d)},h.should.have.properties(d)):4===arguments.length?(this.params={operator:"to have "+a+" "+f(d)},h.should.have.property(d)):(this.params={operator:"to have "+a+" "+f(d)+" with value "+f(m)},h.should.have.property(d,m))}var f=d.format,c=this.jQuery||this.$;"undefined"!==typeof HTMLElement&&HTMLElement&&!HTMLElement.prototype.inspect&&(HTMLElement.prototype.inspect=function(){return this.outerHTML});jQuery.fn.inspect=function(){var b=this.toArray().map(function(b){return g.inspect(b)}).join(", "); -return this.selector?"SELECTOR("+this.selector+") matching "+this.length+" elements"+(b.length?": "+b:""):b};var m=function(b,f,e){a.add(f||b,function(){this.params={operator:"to be "+(e||b)};this.assert(c(this.obj).is(":"+b))},!0)};a.add("className",function(b){this.params={operator:"to have class "+b};this.assert(c(this.obj).hasClass(b))});a.add("css",function(b){this.params={operator:"to have css "+f(b)};for(var a in b){var e=b[a];"auto"===e&&"auto"===c(this.obj).get(0).style[a]||c(this.obj).css(a).should.eql(e)}}); -m("visible");m("hidden");m("selected");m("checked");m("disabled");m("empty","emptyJq");m("focus","focused","focused");a.add("inDOM",function(){this.params={operator:"to be in the DOM"};this.assert(c.contains(document.documentElement,c(this.obj)[0]))},!0);a.add("exist",function(){this.params={operator:"to exist"};c(this.obj).should.not.have.length(0)},!0);a.add("attr",function(){var b=["attr","attribute","attributes"].concat(Array.prototype.slice.call(arguments,0));e.apply(this,b)});a.add("prop",function(){var b= -["prop","property","properties"].concat(Array.prototype.slice.call(arguments,0));e.apply(this,b)});a.add("elementId",function(b){this.params={operator:"to have ID "+f(b)};this.obj.should.have.attr("id",b)});a.add("html",function(b){this.params={operator:"to have HTML "+f(b)};c(this.obj).html().should.eql(c("
").append(b).html())});a.add("containHtml",function(b){this.params={operator:"to contain HTML "+f(b)};c(this.obj).html().indexOf(c("
").append(b).html()).should.be.above(-1)});a.add("text", -function(b){this.params={operator:"to have text "+f(b)};var a=c.trim(c(this.obj).text());g.isRegExp(b)?a.should.match(b):a.should.eql(b)});a.add("containText",function(b){this.params={operator:"to contain text "+f(b)};var a=c.trim(c(this.obj).text());g.isRegExp(b)?a.should.match(b):a.indexOf(b).should.be.above(-1)});a.add("value",function(b){this.params={operator:"to have value "+f(b)};c(this.obj).val().should.eql(b)});a.add("data",function(){var b=["data","data","data"].concat(Array.prototype.slice.call(arguments, -0));e.apply(this,b)});a.add("containElement",function(b){this.params={operator:"to contain "+c(b).inspect()};c(this.obj).find(b).should.not.have.length(0)});a.add("matchedBy",function(b){this.params={operator:"to be matched by selector "+b};c(this.obj).filter(b).should.not.have.length(0)});a.add("handle",function(b){this.params={operator:"to handle "+b};var a=c._data(c(this.obj).get(0),"events");if(!a||!b||"string"!==typeof b)return this.assert(!1);var f=b.split(".");b=f.shift();var e=f.slice(0).sort(), -e=RegExp("(^|\\.)"+e.join("\\.(?:.*\\.)?")+"(\\.|$)");if(a[b]&&f.length){for(f=0;f=a&&this.obj<=e)});d.add("approximately", -function(a,e,f){this.params={operator:"to be approximately "+a+" \u00b1"+e,message:f};this.assert(Math.abs(this.obj-a)<=e)});d.add("above",function(a,e){this.params={operator:"to be above "+a,message:e};this.assert(this.obj>a)});d.add("below",function(a,e){this.params={operator:"to be below "+a,message:e};this.assert(this.objb.indexOf(a)&&h.push(c(a))});this.params={operator:(0===b.length?"to be empty":"to have "+(1===b.length?"key ":"keys "))+b.map(c).join(", ")};0h)return w(g)?a.stylize(RegExp.prototype.toString.call(g),"regexp"):a.stylize("[Object]","special");a.seen.push(g);l=z?b(a,g,h,n,l):l.map(function(b){return p(a, -g,h,n,b,z)});a.seen.pop();return q(l,k,A)}function c(a,b){if(r(b))return a.stylize("undefined","undefined");if(t(b)){var c="'"+JSON.stringify(b).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return a.stylize(c,"string")}if(n(b))return a.stylize(""+b,"number");if(v(b))return a.stylize(""+b,"boolean");if(null===b)return a.stylize("null","null")}function m(a){return"["+Error.prototype.toString.call(a)+"]"}function b(a,b,c,d,f){for(var e=[],g=0,h=b.length;ga.seen.indexOf(b.value)?(k=null===c?f(a,b.value,null):f(a,b.value,c-1),-1a?"0"+a.toString(10):a.toString(10)}function G(){var a=new Date,b=[E(a.getHours()),E(a.getMinutes()),E(a.getSeconds())].join(":");return[a.getDate(),H[a.getMonth()],b].join(" ")}var I=/%[sdj%]/g;d.format=function(a){if(!t(a)){for(var b=[],c=0;c=e)return a;switch(a){case "%s":return String(d[c++]);case "%d":return Number(d[c++]);case "%j":try{return JSON.stringify(d[c++])}catch(b){return"[Circular]"}default:return a}}),f=d[c];c").append(b).html())});a.add("containHtml",function(b){this.params= +{operator:"to contain HTML "+f(b)};c(this.obj).html().indexOf(c("
").append(b).html()).should.be.above(-1)});a.add("text",function(b){this.params={operator:"to have text "+f(b)};var a=c.trim(c(this.obj).text());g.isRegExp(b)?a.should.match(b):a.should.eql(b)});a.add("containText",function(b){this.params={operator:"to contain text "+f(b)};var a=c.trim(c(this.obj).text());g.isRegExp(b)?a.should.match(b):a.indexOf(b).should.be.above(-1)});a.add("value",function(b){this.params={operator:"to have value "+ +f(b)};c(this.obj).val().should.eql(b)});a.add("data",function(){var b=["data","data","data"].concat(Array.prototype.slice.call(arguments,0));e.apply(this,b)});a.add("containElement",function(b){this.params={operator:"to contain "+c(b).inspect()};c(this.obj).find(b).should.not.have.length(0)});a.add("matchedBy",function(b){this.params={operator:"to be matched by selector "+b};c(this.obj).filter(b).should.not.have.length(0)});a.add("handle",function(b){this.params={operator:"to handle "+b};var a=c._data(c(this.obj).get(0), +"events");if(!a||!b||"string"!==typeof b)return this.assert(!1);var f=b.split(".");b=f.shift();var e=f.slice(0).sort(),e=RegExp("(^|\\.)"+e.join("\\.(?:.*\\.)?")+"(\\.|$)");if(a[b]&&f.length){for(f=0;f=a&&this.obj<=e)});d.add("approximately",function(a,e,f){this.params={operator:"to be approximately "+a+" \u00b1"+e,message:f};this.assert(Math.abs(this.obj-a)<=e)});d.add("above",function(a,e){this.params={operator:"to be above "+a,message:e};this.assert(this.obj>a)});d.add("below",function(a,e){this.params={operator:"to be below "+a,message:e};this.assert(this.objb.indexOf(a)&&h.push(c(a))});this.params={operator:(0===b.length?"to be empty":"to have "+(1===b.length?"key ":"keys "))+b.map(c).join(", ")};0h)return w(g)?a.stylize(RegExp.prototype.toString.call(g), +"regexp"):a.stylize("[Object]","special");a.seen.push(g);l=z?b(a,g,h,n,l):l.map(function(b){return p(a,g,h,n,b,z)});a.seen.pop();return q(l,k,A)}function c(a,b){if(r(b))return a.stylize("undefined","undefined");if(t(b)){var c="'"+JSON.stringify(b).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return a.stylize(c,"string")}if(n(b))return a.stylize(""+b,"number");if(v(b))return a.stylize(""+b,"boolean");if(null===b)return a.stylize("null","null")}function m(a){return"["+Error.prototype.toString.call(a)+ +"]"}function b(a,b,c,d,f){for(var e=[],g=0,h=b.length;ga.seen.indexOf(b.value)?(k=null===c?f(a,b.value,null):f(a,b.value,c-1),-1a?"0"+a.toString(10):a.toString(10)}function G(){var a=new Date,b=[E(a.getHours()),E(a.getMinutes()),E(a.getSeconds())].join(":");return[a.getDate(),H[a.getMonth()],b].join(" ")}var I=/%[sdj%]/g;d.format= +function(a){if(!t(a)){for(var b=[],c=0;c=e)return a;switch(a){case "%s":return String(d[c++]);case "%d":return Number(d[c++]);case "%j":try{return JSON.stringify(d[c++])}catch(b){return"[Circular]"}default:return a}}),f=d[c];c