diff --git a/src/ngScenario/dsl.js b/src/ngScenario/dsl.js index f660c3181993..2f3ca18e3d08 100644 --- a/src/ngScenario/dsl.js +++ b/src/ngScenario/dsl.js @@ -298,6 +298,8 @@ angular.scenario.dsl('select', function() { option = select.find('option:contains("' + value + '")'); if (option.length) { select.val(option.val()); + } else { + return done("option '" + value + "' not found"); } } select.trigger('change'); diff --git a/test/ngScenario/dslSpec.js b/test/ngScenario/dslSpec.js index 4a4b17bc8f5d..2db2771c8b51 100644 --- a/test/ngScenario/dslSpec.js +++ b/test/ngScenario/dslSpec.js @@ -269,6 +269,17 @@ describe("angular.scenario.dsl", function() { $root.dsl.select('test').options('A', 'B'); expect($root.futureError).toMatch(/did not match/); }); + + it('should fail to select an option that does not exist', function(){ + doc.append( + '' + ); + $root.dsl.select('test').option('three'); + expect($root.futureError).toMatch(/not found/); + }); }); describe('Element', function() {