mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
feat(scenario): add mouseover method to the ngScenario dsl
This commit is contained in:
parent
faf02f0c4d
commit
2f437e8978
2 changed files with 29 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue