aboutsummaryrefslogtreecommitdiffstats
path: root/test/ngScenario/dslSpec.js
diff options
context:
space:
mode:
authorStephen Merity2013-06-03 18:09:36 +1000
committerPete Bacon Darwin2013-07-12 10:05:23 +0100
commit22a9b1ac07f98d07e1e5d71ce961411b5fa9b42d (patch)
tree3351a4891a8f00a2741551c991b2eb1fb61bfdb3 /test/ngScenario/dslSpec.js
parent7fef06fef9b6af4436f9fed10bd29d0a63707614 (diff)
downloadangular.js-22a9b1ac07f98d07e1e5d71ce961411b5fa9b42d.tar.bz2
fix(ngScenario): select().option(val) should prefer exact value match
With select(...).option(val) it previously would select the first node which contains the value, even if an exact match was available. This fix prefers exact matches if available, otherwise it reverts to the previous 'contains' behaviour for backwards compatibility. Closes #2856
Diffstat (limited to 'test/ngScenario/dslSpec.js')
-rw-r--r--test/ngScenario/dslSpec.js20
1 files changed, 16 insertions, 4 deletions
diff --git a/test/ngScenario/dslSpec.js b/test/ngScenario/dslSpec.js
index 642e2d37..f94ec583 100644
--- a/test/ngScenario/dslSpec.js
+++ b/test/ngScenario/dslSpec.js
@@ -227,6 +227,7 @@ describe("angular.scenario.dsl", function() {
$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(
'<select x-ng-model="test">' +
@@ -238,14 +239,25 @@ describe("angular.scenario.dsl", function() {
expect(doc.find('[x-ng-model="test"]').val()).toEqual('A');
});
+ it('should select option by exact name', function() {
+ doc.append(
+ '<select ng-model="test">' +
+ ' <option value=A>twenty one</option>' +
+ ' <option value=B selected>two</option>' +
+ ' <option value=C>thirty one</option>' +
+ ' <option value=D>one</option>' +
+ '</select>'
+ );
+ $root.dsl.select('test').option('one');
+ expect(doc.find('[ng-model="test"]').val()).toEqual('D');
+ });
-
-
- it('should select option by name', function() {
+ it('should select option by name if no exact match and name contains value', function() {
doc.append(
'<select ng-model="test">' +
- ' <option value=A>one</option>' +
+ ' <option value=A>twenty one</option>' +
' <option value=B selected>two</option>' +
+ ' <option value=C>thirty one</option>' +
'</select>'
);
$root.dsl.select('test').option('one');