diff options
| author | Di Peng | 2011-06-05 11:44:28 -0700 |
|---|---|---|
| committer | Igor Minar | 2011-06-06 12:49:46 -0700 |
| commit | 9fdb09ebf86f4bc85ded08371fbafbab75aba8bf (patch) | |
| tree | 8ce493de4aaf10b8072fb595cd51b40537bf17b8 | |
| parent | 1eebb771e3940ddd6640ddc064d5fa6e539c536d (diff) | |
| download | angular.js-9fdb09ebf86f4bc85ded08371fbafbab75aba8bf.tar.bz2 | |
added input#val method
Closes #237
| -rw-r--r-- | src/scenario/dsl.js | 8 | ||||
| -rw-r--r-- | test/scenario/dslSpec.js | 9 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/scenario/dsl.js b/src/scenario/dsl.js index 9bd0caf7..e9d68f64 100644 --- a/src/scenario/dsl.js +++ b/src/scenario/dsl.js @@ -171,6 +171,7 @@ angular.scenario.dsl('binding', function() { * input(name).enter(value) enters value in input with specified name * input(name).check() checks checkbox * input(name).select(value) selects the radio button with specified name/value + * input(name).val() returns the value of the input. */ angular.scenario.dsl('input', function() { var chain = {}; @@ -201,6 +202,13 @@ angular.scenario.dsl('input', function() { }); }; + chain.val = function() { + return this.addFutureAction("return input val", function($window, $document, done) { + var input = $document.elements(':input[name="$1"]', this.name); + done(null,input.val()); + }); + }; + return function(name) { this.name = name; return chain; diff --git a/test/scenario/dslSpec.js b/test/scenario/dslSpec.js index e1918ca7..1d4ee360 100644 --- a/test/scenario/dslSpec.js +++ b/test/scenario/dslSpec.js @@ -530,8 +530,15 @@ describe("angular.scenario.dsl", function() { chain.select('foo'); expect($root.futureError).toMatch(/did not match/); }); - }); + describe('val', function() { + it('should return value in text input', function() { + doc.append('<input name="test.input" value="something">'); + $root.dsl.input('test.input').val(); + expect($root.futureResult).toEqual("something"); + }); + }); + }); describe('Textarea', function() { |
