feat(scenario): add mouseover method to the ngScenario dsl

This commit is contained in:
Pedro Del Gallego 2013-01-18 21:24:07 -08:00 committed by Misko Hevery
parent faf02f0c4d
commit 2f437e8978
2 changed files with 29 additions and 0 deletions

View file

@ -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);

View file

@ -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();