Comparing version 0.0.3 to 0.0.4
@@ -16,5 +16,19 @@ (function() { | ||
}; | ||
var gen2_rethrowErrors = function(continuation, block) { | ||
return function(error, result) { | ||
if (error) { | ||
return continuation(error); | ||
} else { | ||
try { | ||
return block(result); | ||
} catch (ex) { | ||
return continuation(ex); | ||
} | ||
} | ||
}; | ||
}; | ||
var self = this; | ||
var finders; | ||
var finders, waitUntil; | ||
finders = require("./finders"); | ||
waitUntil = require("./waitUntil").waitUntil; | ||
module.exports = function(element) { | ||
@@ -37,10 +51,10 @@ var self = this; | ||
return { | ||
click: function(locator, gen2_options, continuation) { | ||
click: function(locator, gen3_options, continuation) { | ||
var self = this; | ||
var gen3_arguments = Array.prototype.slice.call(arguments, 0, arguments.length - 1); | ||
var gen4_arguments = Array.prototype.slice.call(arguments, 0, arguments.length - 1); | ||
continuation = gen1_continuationOrDefault(arguments); | ||
locator = gen3_arguments[0]; | ||
gen2_options = gen3_arguments[1]; | ||
locator = gen4_arguments[0]; | ||
gen3_options = gen4_arguments[1]; | ||
var first; | ||
first = gen2_options !== void 0 && Object.prototype.hasOwnProperty.call(gen2_options, "first") && gen2_options.first !== void 0 ? gen2_options.first : false; | ||
first = gen3_options !== void 0 && Object.prototype.hasOwnProperty.call(gen3_options, "first") && gen3_options.first !== void 0 ? gen3_options.first : false; | ||
var el; | ||
@@ -53,10 +67,10 @@ el = find(locator); | ||
}, | ||
select: function(text, gen4_options, continuation) { | ||
select: function(text, gen5_options, continuation) { | ||
var self = this; | ||
var gen5_arguments = Array.prototype.slice.call(arguments, 0, arguments.length - 1); | ||
var gen6_arguments = Array.prototype.slice.call(arguments, 0, arguments.length - 1); | ||
continuation = gen1_continuationOrDefault(arguments); | ||
text = gen5_arguments[0]; | ||
gen4_options = gen5_arguments[1]; | ||
text = gen6_arguments[0]; | ||
gen5_options = gen6_arguments[1]; | ||
var from; | ||
from = gen4_options !== void 0 && Object.prototype.hasOwnProperty.call(gen4_options, "from") && gen4_options.from !== void 0 ? gen4_options.from : void 0; | ||
from = gen5_options !== void 0 && Object.prototype.hasOwnProperty.call(gen5_options, "from") && gen5_options.from !== void 0 ? gen5_options.from : void 0; | ||
var selectElement; | ||
@@ -71,13 +85,21 @@ selectElement = find(from); | ||
}, | ||
fillIn: function(locator, gen6_options, continuation) { | ||
fillIn: function(locator, gen7_options, continuation) { | ||
var self = this; | ||
var gen7_arguments = Array.prototype.slice.call(arguments, 0, arguments.length - 1); | ||
var gen8_arguments = Array.prototype.slice.call(arguments, 0, arguments.length - 1); | ||
continuation = gen1_continuationOrDefault(arguments); | ||
locator = gen7_arguments[0]; | ||
gen6_options = gen7_arguments[1]; | ||
locator = gen8_arguments[0]; | ||
gen7_options = gen8_arguments[1]; | ||
var withValue; | ||
withValue = gen6_options !== void 0 && Object.prototype.hasOwnProperty.call(gen6_options, "withValue") && gen6_options.withValue !== void 0 ? gen6_options.withValue : void 0; | ||
var fillElement; | ||
fillElement = find(locator).val(withValue); | ||
invoke(fillElement, "change", continuation); | ||
withValue = gen7_options !== void 0 && Object.prototype.hasOwnProperty.call(gen7_options, "withValue") && gen7_options.withValue !== void 0 ? gen7_options.withValue : void 0; | ||
return waitUntil(function(continuation) { | ||
var gen9_arguments = Array.prototype.slice.call(arguments, 0, arguments.length - 1); | ||
continuation = gen1_continuationOrDefault(arguments); | ||
return continuation(void 0, find(locator).length > 0); | ||
}, gen2_rethrowErrors(continuation, function(gen10_asyncResult) { | ||
var fillElement; | ||
gen10_asyncResult; | ||
fillElement = find(locator); | ||
fillElement.val(withValue); | ||
invoke(fillElement, "change", continuation); | ||
})); | ||
} | ||
@@ -84,0 +106,0 @@ }; |
@@ -17,8 +17,9 @@ (function() { | ||
var self = this; | ||
var html, configure, run, angularDependencies; | ||
var html, configure, testSetup, run, angularDependencies; | ||
html = gen2_options !== void 0 && Object.prototype.hasOwnProperty.call(gen2_options, "html") && gen2_options.html !== void 0 ? gen2_options.html : void 0; | ||
configure = gen2_options !== void 0 && Object.prototype.hasOwnProperty.call(gen2_options, "configure") && gen2_options.configure !== void 0 ? gen2_options.configure : void 0; | ||
testSetup = gen2_options !== void 0 && Object.prototype.hasOwnProperty.call(gen2_options, "testSetup") && gen2_options.testSetup !== void 0 ? gen2_options.testSetup : void 0; | ||
run = gen2_options !== void 0 && Object.prototype.hasOwnProperty.call(gen2_options, "run") && gen2_options.run !== void 0 ? gen2_options.run : void 0; | ||
angularDependencies = gen2_options !== void 0 && Object.prototype.hasOwnProperty.call(gen2_options, "angularDependencies") && gen2_options.angularDependencies !== void 0 ? gen2_options.angularDependencies : []; | ||
var testModuleName, rootElement, application, injector; | ||
var testModuleName, rootElement, application, element, modules, injector; | ||
testModuleName = "Test" + applicationName; | ||
@@ -40,3 +41,19 @@ rootElement = createElement({ | ||
if (run) { | ||
injector = angular.bootstrap(rootElement[0], [ testModuleName ]); | ||
element = angular.element(rootElement[0]); | ||
modules = [ testModuleName ]; | ||
modules.unshift([ "$provide", function($provide) { | ||
$provide.value("$rootElement", element); | ||
return void 0; | ||
} ]); | ||
modules.unshift("ng"); | ||
injector = angular.injector(modules); | ||
if (testSetup) { | ||
injector.invoke(testSetup); | ||
} | ||
injector.invoke(function($rootScope, $rootElement, $compile, $animate) { | ||
return $rootScope.$apply(function() { | ||
element.data("$injector", injector); | ||
return $compile($rootElement)($rootScope); | ||
}); | ||
}); | ||
return injector.invoke(run); | ||
@@ -43,0 +60,0 @@ } else { |
(function() { | ||
var gen1_continuationOrDefault = function(args) { | ||
var c = args[args.length - 1]; | ||
if (c instanceof Function) { | ||
return c; | ||
} else { | ||
return function(error, result) { | ||
if (error) { | ||
throw error; | ||
} else { | ||
return result; | ||
} | ||
}; | ||
} | ||
}; | ||
var gen2_rethrowErrors = function(continuation, block) { | ||
return function(error, result) { | ||
if (error) { | ||
return continuation(error); | ||
} else { | ||
try { | ||
return block(result); | ||
} catch (ex) { | ||
return continuation(ex); | ||
} | ||
} | ||
}; | ||
}; | ||
var self = this; | ||
var finders; | ||
var finders, waitUntil; | ||
finders = require("./finders"); | ||
waitUntil = require("./waitUntil").waitUntil; | ||
module.exports = function(element) { | ||
@@ -13,2 +41,16 @@ var self = this; | ||
return find(locator).is(":visible"); | ||
}, | ||
hasSelector: function(locator, continuation) { | ||
var self = this; | ||
var gen3_arguments = Array.prototype.slice.call(arguments, 0, arguments.length - 1); | ||
continuation = gen1_continuationOrDefault(arguments); | ||
locator = gen3_arguments[0]; | ||
return waitUntil(function(continuation) { | ||
var gen4_arguments = Array.prototype.slice.call(arguments, 0, arguments.length - 1); | ||
continuation = gen1_continuationOrDefault(arguments); | ||
return continuation(void 0, find(locator).length > 0); | ||
}, gen2_rethrowErrors(continuation, function(gen5_asyncResult) { | ||
gen5_asyncResult; | ||
return continuation(void 0, find(locator).length > 0); | ||
})); | ||
} | ||
@@ -15,0 +57,0 @@ }; |
{ | ||
"name": "chinchilla", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "JQuery backed Capybara like browser automation", | ||
@@ -35,3 +35,3 @@ "main": "build/index.js", | ||
"karma-browserify": "0.0.6", | ||
"pogoify": "0.0.2" | ||
"pogoify": "0.0.4" | ||
}, | ||
@@ -38,0 +38,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1031063
24
26495