aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPedro Del Gallego2013-01-18 21:24:07 -0800
committerMisko Hevery2013-01-18 21:24:57 -0800
commit2f437e89781cb2b449abb685e36b26ca1cf0fff5 (patch)
tree76e5e6bb84750894e4bfae1a525fdab89d15df86
parentfaf02f0c4db7962f863b0da2a82c8cafab2c706f (diff)
downloadangular.js-2f437e89781cb2b449abb685e36b26ca1cf0fff5.tar.bz2
feat(scenario): add mouseover method to the ngScenario dsl
-rw-r--r--src/ngScenario/dsl.js9
-rw-r--r--test/ngScenario/dslSpec.js20
2 files changed, 29 insertions, 0 deletions
diff --git a/src/ngScenario/dsl.js b/src/ngScenario/dsl.js
index 81d74233..9d46e0cf 100644
--- a/src/ngScenario/dsl.js
+++ b/src/ngScenario/dsl.js
@@ -327,6 +327,7 @@ angular.scenario.dsl('select', function() {
* Usage:
* element(selector, label).count() get the number of elements that match selector
* element(selector, label).click() clicks an element
+ * element(selector, label).mouseover() mouseover an element
* element(selector, label).query(fn) executes fn(selectedElements, done)
* element(selector, label).{method}() gets the value (as defined by jQuery, ex. val)
* element(selector, label).{method}(value) sets the value (as defined by jQuery, ex. val)
@@ -383,6 +384,14 @@ angular.scenario.dsl('element', function() {
});
};
+ chain.mouseover = function() {
+ return this.addFutureAction("element '" + this.label + "' mouseover", function($window, $document, done) {
+ var elements = $document.elements();
+ elements.trigger('mouseover');
+ done();
+ });
+ };
+
chain.query = function(fn) {
return this.addFutureAction('element ' + this.label + ' custom query', function($window, $document, done) {
fn.call(this, $document.elements(), done);
diff --git a/test/ngScenario/dslSpec.js b/test/ngScenario/dslSpec.js
index e955b017..28c9ffdc 100644
--- a/test/ngScenario/dslSpec.js
+++ b/test/ngScenario/dslSpec.js
@@ -347,6 +347,26 @@ describe("angular.scenario.dsl", function() {
dealoc(elm);
});
+ it('should execute mouseover', function() {
+ var mousedOver;
+ doc.append('<div></div>');
+ doc.find('div').mouseover(function() {
+ mousedOver = true;
+ });
+ $root.dsl.element('div').mouseover();
+ expect(mousedOver).toBe(true);
+ });
+
+ it('should bubble up the mouseover event', function() {
+ var mousedOver;
+ doc.append('<div id="outer"><div id="inner"></div></div>');
+ doc.find('#outer').mouseover(function() {
+ mousedOver = true;
+ });
+ $root.dsl.element('#inner').mouseover();
+ expect(mousedOver).toBe(true);
+ });
+
it('should count matching elements', function() {
doc.append('<span></span><span></span>');
$root.dsl.element('span').count();