From 249a1d84e7ac3b8528d317b8b0a80acb5dd9a271 Mon Sep 17 00:00:00 2001
From: Adam Macejak
Date: Mon, 29 Oct 2012 21:54:26 -0400
Subject: fix(scenario-runner): support data-ng and x-ng based attributes
Prefixed attributes like data-ng-model and x-ng-model were not being
found by the Selector. It was only looking at ng: and ng- prefixed
attributes.
Added a few tests as well to ensure the aforementioned prefixed
attributes are being matched properly.
Closes #1020
---
src/ngScenario/SpecRunner.js | 4 +++-
test/ngScenario/SpecRunnerSpec.js | 1 -
test/ngScenario/dslSpec.js | 38 ++++++++++++++++++++++++++++++++++++++
3 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/src/ngScenario/SpecRunner.js b/src/ngScenario/SpecRunner.js
index f4b9b0a7..23cc1dc7 100644
--- a/src/ngScenario/SpecRunner.js
+++ b/src/ngScenario/SpecRunner.js
@@ -119,7 +119,9 @@ angular.scenario.SpecRunner.prototype.addFutureAction = function(name, behavior,
});
var result = $document.find(selector);
if (selector.match(NG)) {
- result = result.add(selector.replace(NG, '[ng-'), $document);
+ angular.forEach(['[ng-','[data-ng-','[x-ng-'], function(value, index){
+ result = result.add(selector.replace(NG, value), $document);
+ });
}
if (!result.length) {
throw {
diff --git a/test/ngScenario/SpecRunnerSpec.js b/test/ngScenario/SpecRunnerSpec.js
index c104a9b7..5970607c 100644
--- a/test/ngScenario/SpecRunnerSpec.js
+++ b/test/ngScenario/SpecRunnerSpec.js
@@ -173,5 +173,4 @@ describe('angular.scenario.SpecRunner', function() {
'SpecEnd'
]);
});
-
});
diff --git a/test/ngScenario/dslSpec.js b/test/ngScenario/dslSpec.js
index 9c7893fd..4a4b17bc 100644
--- a/test/ngScenario/dslSpec.js
+++ b/test/ngScenario/dslSpec.js
@@ -217,6 +217,30 @@ describe("angular.scenario.dsl", function() {
expect(doc.find('[ng-model="test"]').val()).toEqual('A');
});
+ it('should select single option using data-ng', function() {
+ doc.append(
+ ''
+ );
+ $root.dsl.select('test').option('A');
+ expect(doc.find('[data-ng-model="test"]').val()).toEqual('A');
+ });
+ it('should select single option using x-ng', function() {
+ doc.append(
+ ''
+ );
+ $root.dsl.select('test').option('A');
+ expect(doc.find('[x-ng-model="test"]').val()).toEqual('A');
+ });
+
+
+
+
it('should select option by name', function() {
doc.append(
'