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

Commit 2f437e8

Browse files
Pedro Del Gallegomhevery
Pedro Del Gallego
authored andcommitted
feat(scenario): add mouseover method to the ngScenario dsl
1 parent faf02f0 commit 2f437e8

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/ngScenario/dsl.js

+9
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ angular.scenario.dsl('select', function() {
327327
* Usage:
328328
* element(selector, label).count() get the number of elements that match selector
329329
* element(selector, label).click() clicks an element
330+
* element(selector, label).mouseover() mouseover an element
330331
* element(selector, label).query(fn) executes fn(selectedElements, done)
331332
* element(selector, label).{method}() gets the value (as defined by jQuery, ex. val)
332333
* element(selector, label).{method}(value) sets the value (as defined by jQuery, ex. val)
@@ -383,6 +384,14 @@ angular.scenario.dsl('element', function() {
383384
});
384385
};
385386

387+
chain.mouseover = function() {
388+
return this.addFutureAction("element '" + this.label + "' mouseover", function($window, $document, done) {
389+
var elements = $document.elements();
390+
elements.trigger('mouseover');
391+
done();
392+
});
393+
};
394+
386395
chain.query = function(fn) {
387396
return this.addFutureAction('element ' + this.label + ' custom query', function($window, $document, done) {
388397
fn.call(this, $document.elements(), done);

test/ngScenario/dslSpec.js

+20
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,26 @@ describe("angular.scenario.dsl", function() {
347347
dealoc(elm);
348348
});
349349

350+
it('should execute mouseover', function() {
351+
var mousedOver;
352+
doc.append('<div></div>');
353+
doc.find('div').mouseover(function() {
354+
mousedOver = true;
355+
});
356+
$root.dsl.element('div').mouseover();
357+
expect(mousedOver).toBe(true);
358+
});
359+
360+
it('should bubble up the mouseover event', function() {
361+
var mousedOver;
362+
doc.append('<div id="outer"><div id="inner"></div></div>');
363+
doc.find('#outer').mouseover(function() {
364+
mousedOver = true;
365+
});
366+
$root.dsl.element('#inner').mouseover();
367+
expect(mousedOver).toBe(true);
368+
});
369+
350370
it('should count matching elements', function() {
351371
doc.append('<span></span><span></span>');
352372
$root.dsl.element('span').count();

0 commit comments

Comments
 (0)