casper-chai
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -18,6 +18,7 @@ | ||
casperChai = function(_chai, utils) { | ||
var _matches; | ||
var methods, properties, _addMethod, _addProperty, _matches; | ||
properties = []; | ||
methods = []; | ||
_matches = function(string_or_regex, value) { | ||
var regex; | ||
console.log(); | ||
if (typeof string_or_regex === 'string') { | ||
@@ -32,3 +33,10 @@ regex = new RegExp("^" + string_or_regex + "$"); | ||
}; | ||
_chai.Assertion.addProperty('inDOM', function() { | ||
assert.casper = {}; | ||
_addProperty = function(name, func) { | ||
return _chai.Assertion.addProperty(name, func); | ||
}; | ||
_addMethod = function(name, method) { | ||
return _chai.Assertion.addMethod(name, method); | ||
}; | ||
_addProperty('inDOM', function() { | ||
var selector; | ||
@@ -38,3 +46,3 @@ selector = this._obj; | ||
}); | ||
_chai.Assertion.addProperty('visible', function() { | ||
_addProperty('visible', function() { | ||
var selector; | ||
@@ -45,3 +53,3 @@ selector = this._obj; | ||
}); | ||
_chai.Assertion.addProperty('loaded', function() { | ||
_addProperty('loaded', function() { | ||
var resourceTest; | ||
@@ -51,3 +59,3 @@ resourceTest = this._obj; | ||
}); | ||
_chai.Assertion.addProperty('matchTitle', function() { | ||
_addProperty('matchTitle', function() { | ||
var matcher, title; | ||
@@ -58,3 +66,3 @@ matcher = this._obj; | ||
}); | ||
_chai.Assertion.addProperty('matchCurrentUrl', function() { | ||
_addProperty('matchCurrentUrl', function() { | ||
var currentUrl, matcher; | ||
@@ -65,3 +73,3 @@ matcher = this._obj; | ||
}); | ||
_chai.Assertion.addProperty('textInDOM', function() { | ||
_addProperty('textInDOM', function() { | ||
var haystack, needle; | ||
@@ -74,3 +82,3 @@ needle = this._obj; | ||
}); | ||
_chai.Assertion.addMethod('textMatch', function(matcher) { | ||
_addMethod('textMatch', function(matcher) { | ||
var selector, text; | ||
@@ -81,3 +89,3 @@ selector = this._obj; | ||
}); | ||
return _chai.Assertion.addMethod('fieldValue', function(givenValue) { | ||
return _addMethod('fieldValue', function(givenValue) { | ||
var get_remote_value, remoteValue, selector; | ||
@@ -84,0 +92,0 @@ selector = this._obj; |
@@ -1,1 +0,1 @@ | ||
(function(){var t;t=function(t,e){var i;i=function(t,e){var i;console.log();if(typeof t==="string"){i=new RegExp("^"+t+"$")}else if(_.isRegExp(t)){i=t}else{throw new Error("Test received "+t+", but expected string",+" or regular expression.")}return i.test(e)};t.Assertion.addProperty("inDOM",function(){var t;t=this._obj;return this.assert(casper.exists(t),"expected selector #{this} to be in the DOM, but it was not","expected selector #{this} to not be in the DOM, but it was")});t.Assertion.addProperty("visible",function(){var t;t=this._obj;expect(t).to.be.inDOM;return this.assert(casper.visible(t),"expected selector #{this} to be visible, but it was not","expected selector #{this} to not be, but it was")});t.Assertion.addProperty("loaded",function(){var t;t=this._obj;return this.assert(casper.resourceExists(t),"expected resource #{this} to exist, but it does not","expected resource #{this} to not exist, but it does")});t.Assertion.addProperty("matchTitle",function(){var t,e;t=this._obj;e=casper.getTitle();return this.assert(i(t,e),"expected title #{this} to match #{exp}, but it did not","expected title #{this} to not match #{exp}, but it did")});t.Assertion.addProperty("matchCurrentUrl",function(){var t,e;e=this._obj;t=casper.getCurrentUrl();return this.assert(i(e,t),"expected url #{exp} to match #{this}, but it did not","expected url #{exp} to not match #{this}, but it did")});t.Assertion.addProperty("textInDOM",function(){var t,e;e=this._obj;t=casper.evaluate(function(){return document.body.textContent||document.body.innerText});return this.assert(t.indexOf(e)!==-1,"expected text #{this} to be in the document, but it was not","expected text #{this} to not be in the document, but it was found")});t.Assertion.addMethod("textMatch",function(t){var e,s;e=this._obj;s=casper.fetchText(e);return this.assert(i(t,s),"expected '"+e+"' to match "+t+", but it did not","expected '"+e+"' to not match "+t+", but it did")});return t.Assertion.addMethod("fieldValue",function(t){var e,i,s;s=this._obj;if(_.isString(s)){}else{expect(s).to.be.inDOM}e=function(t){return __utils__.getFieldValue(t)};i=casper.evaluate(e,{selector:s});return this.assert(i===t,"expected field(s) "+s+" to have value "+t+", "+("but it was "+i),"expected field(s) "+s+" to not have value "+t+", "+"but it was")})};if(typeof require==="function"&&typeof exports==="object"&&typeof module==="object"){module.exports=t}else if(typeof define==="function"&&define.amd){define(function(){return t})}else{chai.use(t)}}).call(this); | ||
(function(){var t;t=function(t,e){var i,s,r,n,o;s=[];i=[];o=function(t,e){var i;if(typeof t==="string"){i=new RegExp("^"+t+"$")}else if(_.isRegExp(t)){i=t}else{throw new Error("Test received "+t+", but expected string",+" or regular expression.")}return i.test(e)};assert.casper={};n=function(e,i){return t.Assertion.addProperty(e,i)};r=function(e,i){return t.Assertion.addMethod(e,i)};n("inDOM",function(){var t;t=this._obj;return this.assert(casper.exists(t),"expected selector #{this} to be in the DOM, but it was not","expected selector #{this} to not be in the DOM, but it was")});n("visible",function(){var t;t=this._obj;expect(t).to.be.inDOM;return this.assert(casper.visible(t),"expected selector #{this} to be visible, but it was not","expected selector #{this} to not be, but it was")});n("loaded",function(){var t;t=this._obj;return this.assert(casper.resourceExists(t),"expected resource #{this} to exist, but it does not","expected resource #{this} to not exist, but it does")});n("matchTitle",function(){var t,e;t=this._obj;e=casper.getTitle();return this.assert(o(t,e),"expected title #{this} to match #{exp}, but it did not","expected title #{this} to not match #{exp}, but it did")});n("matchCurrentUrl",function(){var t,e;e=this._obj;t=casper.getCurrentUrl();return this.assert(o(e,t),"expected url #{exp} to match #{this}, but it did not","expected url #{exp} to not match #{this}, but it did")});n("textInDOM",function(){var t,e;e=this._obj;t=casper.evaluate(function(){return document.body.textContent||document.body.innerText});return this.assert(t.indexOf(e)!==-1,"expected text #{this} to be in the document, but it was not","expected text #{this} to not be in the document, but it was found")});r("textMatch",function(t){var e,i;e=this._obj;i=casper.fetchText(e);return this.assert(o(t,i),"expected '"+e+"' to match "+t+", but it did not","expected '"+e+"' to not match "+t+", but it did")});return r("fieldValue",function(t){var e,i,s;s=this._obj;if(_.isString(s)){}else{expect(s).to.be.inDOM}e=function(t){return __utils__.getFieldValue(t)};i=casper.evaluate(e,{selector:s});return this.assert(i===t,"expected field(s) "+s+" to have value "+t+", "+("but it was "+i),"expected field(s) "+s+" to not have value "+t+", "+"but it was")})};if(typeof require==="function"&&typeof exports==="object"&&typeof module==="object"){module.exports=t}else if(typeof define==="function"&&define.amd){define(function(){return t})}else{chai.use(t)}}).call(this); |
@@ -10,3 +10,3 @@ { | ||
], | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"author": "Brian M Hunt <brianmhunt@gmail.com>", | ||
@@ -26,3 +26,3 @@ "license": "MIT", | ||
"scripts": { | ||
"test": "mocha", | ||
"test": "cake test", | ||
"lint": "jshint ./lib" | ||
@@ -29,0 +29,0 @@ }, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7446
402399
9
2
0