Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
feat(scenario): add mouseover method to the ngScenario dsl
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Del Gallego authored and mhevery committed Jan 19, 2013
1 parent faf02f0 commit 2f437e8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/ngScenario/dsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down
20 changes: 20 additions & 0 deletions test/ngScenario/dslSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 2f437e8

Please sign in to comment.