aboutsummaryrefslogtreecommitdiffstats
path: root/test/scenario/dslSpec.js
diff options
context:
space:
mode:
authorVojta Jina2011-08-30 13:14:55 +0200
committerVojta Jina2011-09-08 23:00:59 +0200
commit66dec7755573a1c07a1fe8e0dd9bc5fc51dbaac9 (patch)
treedcdefd40fc34251dbc704808ce20396b1453b371 /test/scenario/dslSpec.js
parent8fa79066e2cea470086769aa59e7cc9d3aa30d81 (diff)
downloadangular.js-66dec7755573a1c07a1fe8e0dd9bc5fc51dbaac9.tar.bz2
fix(scenario): do not navigate if click event was cancelled
This is jQuery incompatible hack. But we were doing monkey patching there anyway... `$(...).trigger('click')` returns an array of return values, so that scenario runner knows, whether the event default action was cancelled. Without this fix, scenario runner was doing navigation even if JS code called `event.preventDefault()`. Note, this does not work in FF6
Diffstat (limited to 'test/scenario/dslSpec.js')
-rw-r--r--test/scenario/dslSpec.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/scenario/dslSpec.js b/test/scenario/dslSpec.js
index 5485fe52..8e22e469 100644
--- a/test/scenario/dslSpec.js
+++ b/test/scenario/dslSpec.js
@@ -250,6 +250,20 @@ describe("angular.scenario.dsl", function() {
expect($window.location).toMatch(/#foo$/);
});
+ it('should not navigate if click event was cancelled', function() {
+ var initLocation = $window.location,
+ elm = jqLite('<a href="#foo"></a>');
+
+ doc.append(elm);
+ elm.bind('click', function(event) {
+ event.preventDefault();
+ });
+
+ $root.dsl.element('a').click();
+ expect($window.location).toBe(initLocation);
+ dealoc(elm);
+ });
+
it('should count matching elements', function() {
doc.append('<span></span><span></span>');
$root.dsl.element('span').count();